Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
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.