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

CloudFlare: Users Suddenly Showing CF IPs Again

Discussion in 'Troubleshooting and Problems' started by taylor_smith, Jul 2, 2012.

  1. taylor_smith

    taylor_smith Well-Known Member

    Previously, adding this to config.php allowed XenForo to record user IPs, despite CloudFlare.

    Code:
    if (isset($_SERVER['HTTP_CF_CONNECTING_IP']))
    {
    $_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_CF_CONNECTING_IP'];
    }
    As of today, I see lots of users all sharing CloudFlare IPs. Checked config.php and the above code is still there. Anyone else seeing the same? Have any possible solutions?
     
  2. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Visit admin.php?tools/phpinfo and make sure REMOTE_ADDR shows your correct IP. If it's not correct then you can contact your host or server person to fix this. Or look for a server variable that contains the correct IP and then add this code to your library/config.php file:

    Code:
    // FIX IP ADDRESS FOR PROXY
    $_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_X_REAL_IP'];
    
    Replace the red part with the name of the server variable that contains the correct IP (from your phpinfo).
     
    taylor_smith likes this.
  3. taylor_smith

    taylor_smith Well-Known Member

    It seems to be showing my IP correctly. Hmm.
     
  4. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Well you were previously using HTTP_CF_CONNECTING_IP, so maybe that is incorrect in which case you need to revert to REMOTE_ADDR which is the default (remove your config.php code), or change your code to use whatever variable shows the correct IP.
     
  5. taylor_smith

    taylor_smith Well-Known Member

    What would the code be in that case? Initially, all users were sharing the CloudFlare IP. Wouldn't removing the code return us to this?

    Sorry, I'm not very technical.
     
  6. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    You said REMOTE_ADDR shows your correct IP? Then just remove your config.php code. XF uses REMOTE_ADDR by default so if it's correct then you don't need to change it with config.php code.
     
    taylor_smith likes this.
  7. taylor_smith

    taylor_smith Well-Known Member

    Cool, will give it a shot. Thanks. :)
     
  8. taylor_smith

    taylor_smith Well-Known Member

    Unfortunately, when I removed it, my first post showed a CloudFlare IP.

    Eh, maybe my host disabled something for a while, or maybe CloudFlare had some kind of update. I dunno.
     

Share This Page