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

Wrong IP address?

Kevin

Well-known member
#1
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:
 

Kevin

Well-known member
#3
Might be a proxy messing up the IP reporting. See my posts in this thread, starting with this one:

http://xenforo.com/community/threads/always-1-guest-online.23143/#post-287651
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.
 

Jake Bunce

XenForo moderator
Staff member
#4
Do you see your correct IP address anywhere on the PHP info page? It might be in a different server variable.
 

Kevin

Well-known member
#5
Do you see your correct IP address anywhere on the PHP info page? It might be in a different server variable.
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).
 

Jake Bunce

XenForo moderator
Staff member
#6
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.
 

Kevin

Well-known member
#7
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).
Does not appear to be any other variables available.

Otherwise you would have to contact your host to work this out.
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:
 

Kevin

Well-known member
#8
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.