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

Wrong IP address?

Discussion in 'Troubleshooting and Problems' started by Kevin, Jun 6, 2012.

  1. Kevin

    Kevin Well-Known Member

    I've been noticing lately that the IP address shown for myself from the Current Members page isn't always consistent.

    To clarify... if I Google 'what is my ip' (or go to a IP site) I might get an address that ends in .101 but... if I visit 5 different XF sites I see an an address that ends in .163 on 2 out of the 5 sites.

    Anybody else seeing similar oddities with the IP? If not, any thoughts on why I might be getting these results? :confused:
     
  2. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

  3. Kevin

    Kevin Well-Known Member

    Thanks, sounds like the same problem even though I'm not using Nginx or behind a proxy. I tried the change to config.php you posted in that thread but it results in a "An unexpected error occurred. Please try again later." error.

    EDIT: Viewing the PHP Info page the right address is shown for REMOTE_ADDR in the Apache Environment section but not for _SERVER["REMOTE_ADDR"] in the PHP Variables section. There is no HTTP_X_REAL_IP variable listed which is likely causing my error when I try the change to the config file.
     
  4. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Do you see your correct IP address anywhere on the PHP info page? It might be in a different server variable.
     
  5. Kevin

    Kevin Well-Known Member

    I was thinking the same... :D There are only a few IP addresses listed and, excluding the server IP, I only have REMOTE_ADDR available as a PHP variable. I checked the same thing on one of the sites that is working (same server, nearly identical config file with the differences being the cache prefix & DB settings of course) and there it is correct in both spots (Apache environment & PHP variable).
     
  6. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Well if you can find a server variable that contains the correct IP then you can use that in the config file (per the other thread I linked to). Otherwise you would have to contact your host to work this out.
     
  7. Kevin

    Kevin Well-Known Member

    Does not appear to be any other variables available.

    Well, that'd be me since the sites in question are all on the same dedicated server and, except for the differences noted above, have been installed & configured the same with fresh XF installations. :coffee:
     
  8. Kevin

    Kevin Well-Known Member

    For those having the same issue, found a fix that works for me (your mileage, of course, may vary)...

    In your config.php file add the following:
    Code:
    // FIX FOR SERVER REMOTE_ADDR IP ADDRESS NOT MACTCHING APACHE ENVIRONMENT IP
    $_SERVER['REMOTE_ADDR'] = getenv('REMOTE_ADDR');
    
    With the above in place my IP is now showing correctly in Current Visitors and my phantom guest listing is gone.
     
    Jake Bunce likes this.

Share This Page