0

I've a little problem with nginx, acting both as reverse proxy and proxified server.

On the front server, my configuration is:

server {
        server_name example.com;

        location / {
                proxy_set_header Host $host;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_pass http://10.2.2.1:8999;
        }
}

And on the proxified server:

server {
    listen 10.2.2.1:8999;

    server_name example.com;
    autoindex on;

    location / {
        root /var/www/;
    }
}

Finally, on this proxified server, a directory /var/www/test exists with some files inside.

The problem occurs when I try to access to http://example.com/test (without trailing slash!): my browser is redirected to http://example.com:8999/test/... If I try to access to http://example.com/test/, no problem.

I've tried proxy_redirect statement which, from what I understand, allow the reverse proxy to rewrite Location header to avoid this kind of behavior, but this didn't worked for me. why?.

My second question is, why profixied nginx redirect me to this URL ? How I can prevent it to do that ?

Thanks by advance for any help.

1 Answer 1

2

Turn off port_in_redirect on the backend server.

2
  • Thanks, I hadn't seen this option ! But the nginx redirection can it be disabled ?
    – Antoine
    Jul 18, 2011 at 18:40
  • What would you want it to do if /test is requested? Return a 404? It won't generate the directory index without the trailing slash.
    – kolbyjack
    Jul 18, 2011 at 19:26

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .