Sign up ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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

On the front server, my configuration is:

server {

        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;

And on the proxified server:

server {

    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 (without trailing slash!): my browser is redirected to If I try to access to, 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.

share|improve this question

1 Answer 1

up vote 2 down vote accepted

Turn off port_in_redirect on the backend server.

share|improve this answer
Thanks, I hadn't seen this option ! But the nginx redirection can it be disabled ? – Antoine Jul 18 '11 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 '11 at 19:26

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.