Quantcast
Channel: Nginx Forum - Nginx Mailing List - English
Viewing all articles
Browse latest Browse all 7229

Problem with a reverse proxy and trailing slash redirects (1 reply)

$
0
0
Hello

We have a service for our customers that allows them to test their site
before they point their DNS to our servers. It works like this: we
configure their websites in our backend servers as usual, and we create
an entry in a zone we own. Say the customer's site is www.foo.com; we
give him a temporary address at foo.tmpzone.com where he can try our
services without changing his DNS records.

This is done by configuring foo.tmpzone.com in Nginx, which then
redirects to the backend server:

server {
listen 1.2.3.4:80;
server_name foo.tmpzone.com;

location / {
proxy_pass http://4.3.2.1;
proxy_redirect http://4.3.2.1/ http://$host/;
proxy_set_header Host www.foo.com;
}
}

The problem with this setup is that if one tries to access, say,
foo.tmpzone.com/blah, Nginx will issue a 301 redirect adding a trailing
slash, but the Location will be set to "www.foo.com/blah/". This seems
to be due to the proxy_set_header directive, which is needed for the
backend server to find the appropriate virtual host.

Is there any way to override this behavior and have Nginx redirect to
foo.tmpzone.com/blah/ instead? I tried turning on the
server_name_in_redirect directive, but it didn't work.

Thanks in advance,
Andre


_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx

Viewing all articles
Browse latest Browse all 7229

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>