nginx redirects back to remote_addr IP

Discussion in 'Server Operation' started by bzzik, Feb 24, 2012.

  1. bzzik

    bzzik New Member

    Hi ppl ;)

    I am trying to setup nginx 1.0.12 as a proxy for apache 2.2.15, but faced strange problem. And I cannot solve it for third day in a row :(
    I have test site and have installed roundcube in /roundcube subdirectory. So here is the problem:

    If you will try to open you will get strange redirect back to your own IP address. So nginx tries to download static files from remote_addr. But if you will add trailing slash to uri it will work.

    Another example: try to open - you also will get redirect back to your own IP address and again nginx tries to download static files from remote_addr.

    Interesting thing is that connencting through apache works nice:

    I really need your advice how to fix it, cause I am stuck :confused:

    Here is my config files:


    In apache httpd.conf I have:
    Thank you in advance for any advice you have :)
    Last edited: Feb 24, 2012
  2. Carlinforge

    Carlinforge New Member

    is this now working?

    i reviewed the post and hello from does not redirect. Pls reply with an update as this is great way for newbie to learn ... thx in advance

  3. bzzik

    bzzik New Member

    Yeah, this one does not redirect.
    But and does... And this driving me crazy. :mad:
  4. falko

    falko Super Moderator ISPConfig Developer is working for me as well, while isn't.

    The only difference in your vhosts that I see is server_name_in_redirect off;
  5. bzzik

    bzzik New Member - you do not have any redirects? Sure that it opens normally without trailing slash?

    I put server_name_in_redirect off; to, but it did not help...

    Ok, I think I found the problem. For some reason $_SERVER["HTTP_HOST"] is incorrect - it is getting equal to $remote_addr, but not always... this is weird. I am trying to understand how does this happen, is it nginx, apache or PHP problem?

    Update 2:
    So this sounds like nginx problem... you can check two test addresses: and You can see, that HTTP_POST is different on nginx and apache...
    Last edited: Feb 26, 2012
  6. bzzik

    bzzik New Member

    I solved one of the problems. On another forum user adviced me to change $host to $http_host in the proxy.conf and add there new line:
    $_SERVER["HTTP_HOST"] is correct now and is working :) In fact after adding this line
    everything it started to work. But in all tutorials about nginx as reverse_proxy there is nothing about this line...

    And the problem with trailing slash still exists: still redirects back to $remote_addr. :(
    Last edited: Feb 26, 2012

Share This Page