nginx : Http Response code for redirected request's response -
we use nginx reverse proxy. nginx follow redirects proxy , use location header on 302. working using intercepting errors(proxy_intercept_errors on) , following redirects using location header when 302 received upstream server. but, http response code response still 302. tried both browser , curl. expected behavior? posted relevant config..hope 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 config below
server { location / { proxy_intercept_errors on; error_page 302 301 307 = @handle_redirects; } location @handle_redirects { set $redirect_upstream_http_location $upstream_http_location; proxy_pass $redirect_upstream_http_location; } }
from nginx documentation
furthermore, possible change response code using “=response” syntax, example:
error_page 404 =200 /empty.gif; if error response processed proxied server or fastcgi/uwsgi/scgi server, , server may return different response codes (e.g., 200, 302, 401 or 404), possible respond code returns:
error_page 404 = /404.php;
Comments
Post a Comment