1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

X-Forwarded-For IP

Discussion in 'Installation, Upgrade, and Import Support' started by AWS, Mar 2, 2013.

  1. AWS

    AWS Well-Known Member

    I am in the process of converting one of my forums from IPB.

    This is hosted on a server on my network. I have a load balancing router in front of the server. Since this server is on the network I use to surf the internet whenever I post it grabs my router IP instead of the X-Forwarded-For IP which would be my actual IP.

    The server is a new uBuntu box that I just put online. I also have Varnish installed although I am not using it for this site yet.

    On IPB there was an option to turn on X-Forwarded-For and with it enabled my real IP comes through. Without it I have the same problem. I know xenforo can be used with cloudflare so either I am missing something with my configuration or xenforo isn't grabbing that header.
  2. Deebs

    Deebs Well-Known Member

    Just put the following at the top of config.php
    if (isset($_SERVER['HTTP_X_FORWARDED_FOR']))
  3. AWS

    AWS Well-Known Member

    I did do that. Should have mentioned that. I have the same problem with IIS and request_uri so I use a similar block of code on them. I should have mentioned that.

    From what I'm seeing it looks to be a common problem although none of the fixes I've found work. Maybe once I put the site behind Varnish it will start working correctly. The IIS sites work without the fix once I put them behind Varnish.
  4. AWS

    AWS Well-Known Member

    There is a bug in the x-forwarded-for in Apache. Because of my network configuration my x-forwarded-for header has 3 IP's if I connect to the server from my network which I do. Apache and nginx which I just setup to replace Apache see all 3 IP's, but, the use the first IP instead of the last which would be the public network IP.

    Varnish doesn't have this problem so I plugged in the server to the Varnish config and all works as expected now.

Share This Page