© 2023 Ezoic Inc.
|
Privacy Policy
Jump to:
What Is The X-Forwarded-For Header?
When Is The X-Forwarded-For Header Used?
Why Would The Original IP Of The User Not Get Passed Along When Using Ezoic?
How to add the X-Forwarded-For (XFF) header in .PHP and .NET?
How to Add the X-Forwarded-For (XFF) Header on WordPress?
Where to add the X-Forwarded-For code in the wp-config.php file?
The X-Forwarded-For (XFF) Header identifies the originating IP address of a user in server access logs, through an HTTP proxy or load balancer.
Many web applications use the origin IP address of the user. An example of when the X-Forwarded-For Header would be needed might be if a site identifies users by their IP address when logging into a member area. In this case, the origin IP needs to be passed along.
When using Ezoic's platform, requests from your website visitors will be routed through Ezoic's Amazon Cloud Servers (AWS). Therefore, your access logs will show Ezoic IP addresses rather than the original IP address of the user.
Occasionally, your hosting company misinterprets requests going via Ezoic as a bot attack, because all the requests are coming from a single or a few IPs rather than a wide assortment.
Errors you might see in relation to this issue include origin errors, 520 errors, or your host's Robot Captcha.
This issue can be fixed by using the XFF header.
By implementing the XFF header, Ezoic will send the IP address of the original web visitor through to your server in the X-Forwarded-For header.
How to add the X-Forwarded-For (XFF) header in .PHP and .NET?
For Wordpress sites this process is a little different.
To implement XFF for WordPress sites, simply copy and paste the code below to your wp-config.php file:
// Use X-Forwarded-For HTTP Header to Get Visitor's Real IP Address
if ( isset( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) {
$http_x_headers = explode( ',', $_SERVER['HTTP_X_FORWARDED_FOR'] );
$_SERVER['REMOTE_ADDR'] = $http_x_headers[0];
}
This will differ depending upon your theme. If you are unsure, please contact your theme's owners.
Alternatively, the Proxy Real IP Wordpress plugin can add the code for you:
https://wordpress.org/plugins/proxy-real-ip/
Anything else?
Yes! Please let your host know when you have implemented a X-Forwarded-For header. They will need to perform additional configuration on their end to allow the requests to pass through as expected.