location / {
proxy_pass /newurl/;
}
location /newurl {
return 303 /old/users;
}
I am trying to access / and getting 502 error, as my proxy to /newurl is returning an error 301. Is there some way I can proxy and get the 301 error with the same content to UI?
Instead of using proxy_pass take a look at the rewrite directive.
You are receiving the 502 error message because the proxy_pass directive in your snippet is not pointing to a valid URL.
location / {
rewrite ^ /newurl break;
}
I would suggest share a complete nginx block so we can see what you doing wrong
server {
. . .
server_name example.com www.example.com;
rewrite ^/products.html$ /offer.html permanent;
rewrite ^/services.html$ /offer.html permanent;
. . .
}