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

Show proper IP when behind reverse-proxy

Discussion in 'XenForo Suggestions' started by Ralle, Mar 31, 2016.

  1. Ralle

    Ralle Active Member

    Many people use reverse-proxies these days. Common types are Cloudflare, Varnish, Nginx. Reverse-proxies work just fine with XenForo, however, when looking at the IP log, you will find that ALL registered IPs are by your proxy and not your user.
    Because of this, I suggest that we add an option to the Options page allowing you to look at the 'X-Forwarded-For' header stead of REMOTE_ADDR.

    Basically, this would add a bit more logic to XenForo_Helper_Ip where it looks at $request->getServer('
    HTTP_X_FORWARDED_FOR'] but only if the option was enabled.

    I would like the option to exist because many people are not using proxies and if there is no proxy, people can fake their IP with this instead.

    I could do this myself if XenForo_Helper_Ip was dynamically loaded like many other classes are. Sadly, it isn't :(.
  2. Brogan

    Brogan XenForo Moderator Staff Member

    It may not be the HTTP_X_FORWARDED_FOR setting which needs to be changed though - it depends on server configuration.

    It could be HTTP_CF_CONNECTING_IP, _SERVER['HTTP_X_REAL_IP'] or some other _SERVER value.

    The best way to manage this is by editing the config,php file.
  3. James

    James Well-Known Member

  4. Ralle

    Ralle Active Member

    Ah that is excellent. I am sorry for asking a frequently asked question.

Share This Page