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

XF 1.5 X_FORWARDED_FOR

trman

Active member
#1
I am using Ezoic, which puts my forum behind a proxy and my forum visitors original IP address does not show in my ACP, just the IP address of that Ezoic uses.

I think I need to use X_FORWARDED_FOR somewhere to get the real IP to show up. I have tried to put the following in config.php and it did not work:

Code:
$_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_X_FORWARDED_FOR'];
Ezoic is not much help, other than telling me I need to use X_FORWARDED_FOR.

Can anyone help?
 

trman

Active member
#3
Thanks Chris,

I changed it however now instead of showing the visitor ip as 127.0.0.1 it is blank in the AdminCp (under users awaiting approval).

I want to get the user's original IP address and use it in Xenforo for all the IP related functions, such as stop forum spam where the IP is checked, and so on.

Here is what I now have in my /library/config.php

Code:
$_SERVER['REMOTE_ADDR'] = $_SERVER['X_FORWARDED_FOR'];
 

trman

Active member
#4
You're using:
Code:
$_SERVER['HTTP_X_FORWARDED_FOR'];
rather than:
Code:
$_SERVER['X_FORWARDED_FOR'];

Clarification:

Code:
$_SERVER['HTTP_X_FORWARDED_FOR'];
shows visitor ip address as 127.0.0.1

Code:
$_SERVER['X_FORWARDED_FOR'];
shows no visitor ip address
 

Chris D

XenForo developer
Staff member
#5
If the advice that Ezoic has given you doesn't appear to be correct, then you may have to clarify the issue with them directly.
 

trman

Active member
#6
Ezoic really did not give me any advice, other than to get the visitors original IP address I needed to implement X_Forwarded_FOR.

So I am just trying to figure out how to do that with Xenforo.
 

Chris D

XenForo developer
Staff member
#7
Sorry I wasn't clear: you are doing it correctly in XenForo, but it would appear as though the headers they recommended aren't returning the correct information.

So, this is absolutely correct:
Here is what I now have in my /library/config.php

Code:
$_SERVER['REMOTE_ADDR'] = $_SERVER['X'];
But you just need to clear up with them whatever the "X" is and question why it isn't returning the expected value. FWIW, I have since looked into various bits and "HTTP_X_FORWARDED_FOR" is indeed a valid header that some proxy providers set, which I believe is returning an empty string for you, so assuming now that is the correct header the question remains why is it blank, and that's something really only they can answer.