I have an nginx-based HTTP proxy and I would like to process all HTTP redirects inside it so that clients get only the last response in the redirect chain.
The basic code looks like:
location /proxy {
rewrite ^/proxy/([^/]+) $1 break;
proxy_pass http://$uri/;
}
My attempt at following 1 level redirects is this:
error_page 301 302 307 =200 @redir;
... and having this named location:
location @redir {
proxy_pass $proxy_location;
}
Only there's no $proxy_location variable and I failed to find a way of creating it. It should contain the value of Location:
header received from upstream.
Any thoughts?