We use nginx as reverse proxy. We would like nginx to follow redirects from proxy and use the Location header on 302. I could get this working using intercepting errors(proxy_intercept_errors on) and following the redirects using the Location header when 302 is received from upstream server. However, the http response code for this response is still 302. I tried both the browser and curl. Is this an expected behavior? Posted the relevant config. Hope this helps.
server {
location / {
proxy_intercept_errors on;
error_page 302 @handle_redirects;
} location @handle_redirects {
set $redirect_upstream_http_location $upstream_http_location;
proxy_pass $redirect_upstream_http_location;
}
}
Thanks
Change your config to below
From nginx documentation