nginx howto correct the path from a back-end server redirect response under a virtual directory
Posted
by
noname
on Server Fault
See other posts from Server Fault
or by noname
Published on 2010-08-25T22:11:48Z
Indexed on
2011/03/13
8:11 UTC
Read the original article
Hit count: 290
The following was my deployed servers:
client ------ nginx proxy(example.com) ------ back-end server(192.168.1.20)
The nginx proxy's external URL was configured under a virtual directory http://example.com/demo/ The back-end server was configure to http://192.168.1.20:8080/
the following was part of the nginx configure file:
location /demo {
proxy_pass http://192.168.1.20:8080/;
proxy_redirect default;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
When the back-end server send a redirect response (HTTP CODE 302) with LOCATION head field "http://192.168.1.20/subdir/", the nginx map this LOCATION header field to "http://example.com/subdir/", not the disired "http://example.com/demo/subdir/"
© Server Fault or respective owner