<div dir="ltr"><div><div><div>Hello, <br>Is there an easy way to configure nginx upstream to follow 302 instead of send them to the browser?<br><br></div>I tried with this config:<br><br>http {<br> proxy_intercept_errors on;<br>
<br> proxy_cache_path /home/toli/nginx/run/cache keys_zone=zone_c1:256m inactive=5d max_size=30g;<br> <br> upstream up_servers {<br> server <a href="http://127.0.1.1:8081">127.0.1.1:8081</a>;<br> }<br><br>
server {<br> listen <a href="http://127.0.0.1:8080">127.0.0.1:8080</a>;<br><br> location / {<br> proxy_cache zone_c1;<br> proxy_pass <a href="http://127.0.1.1:8081">http://127.0.1.1:8081</a>;<br>
proxy_temp_path tmp ;<br><br> error_page 301 302 307 @redir;<br> }<br><br> location @redir {<br> proxy_cache zone_c1;<br> proxy_pass $upstream_http_location;<br> proxy_temp_path tmp ;<br>
}<br> }<br>}<br><br></div>Unfortunately it do not work. I receive "500: Internal Server Error."<br></div>and in the logs I have [invalid URL prefix in ""]<br><div><div><br></div><div>From dev mail list Maxim advised me to backup $upstream_http_location in other variable and I did it but the result was the same - 500 internal server error. The config after the fix is:<br>
<br><br>http {<br> proxy_intercept_errors on;<br><br> proxy_cache_path /home/toli/nginx/run/cache keys_zone=zone_c1:256m inactive=5d max_size=30g;<br> <br> upstream up_servers {<br> server <a href="http://127.0.1.1:8081">127.0.1.1:8081</a>;<br>
}<br><br> server {<br> listen <a href="http://127.0.0.1:8080">127.0.0.1:8080</a>;<br><br> location / {<br> proxy_cache zone_c1;<br> proxy_pass <a href="http://127.0.1.1:8081">http://127.0.1.1:8081</a>;<br>
proxy_temp_path tmp ;<br></div><div> set $foo $upstream_http_location;</div><div> error_page 301 302 307 @redir;<br> }<br><br> location @redir {<br> proxy_cache zone_c1;<br>
proxy_pass $foo;<br> proxy_temp_path tmp ;<br> }<br> }<br>}<br><br></div><div>Do you have any idea how this could be achieved.<br><br></div></div></div>