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

IP record - Recording firewall IP instead of user

#1
Hi Community,

I'm currently setting up my forum which is behind a UTM firewall. It seems the code used to record a users IP in Xenforo is using something similar to the following:

$ip = $_SERVER['REMOTE_ADDR']

However, that will return the Firewall IP address and not the user.

I've got some code which will return the correct IP address of the visiting user, but I’m unsure where the actual IP function in Xenforo is to update it?

There are just so many .php files o_O

Any help would be greatly appreciated.

Jack.
 

tyteen4a03

Well-known member
#2
If you aren't looking to write your own addon to do this, putting your IP translation logic in config.php is fine (however hacky it is)
 

Jake Bunce

XenForo moderator
Staff member
#3
There isn't a central function in XenForo for the client IP.

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).
 
#4
Thanks very much that gives me something to work with. REMOTE_ADDR in PHPinfo is just returning the firewall IP, so i'll have a play. I should be able to get it work by editing the config.php file.

Thanks again.
Jack.
 
#5
Hi,

Just a quick update. This variable fixes the problem seeing as the firewall is acting as a proxy server for requests both leaving and coming to the webserver.

HTTP_X_FORWARDED_FOR

Thank you.