Welcome! Log In Create A New Profile

Advanced

Problem with a reverse proxy and trailing slash redirects

Andre Nathan
August 15, 2014 01:34PM
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
Subject Author Posted

Problem with a reverse proxy and trailing slash redirects

Andre Nathan August 15, 2014 01:34PM

Re: Problem with a reverse proxy and trailing slash redirects

Francis Daly August 15, 2014 06:18PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 317
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready