Using the X-Forwarded-For (XFF) Header

Hello All,

I need to Add the X-Forwarded-For (XFF) Header on WordPress on my Flatsome theme following the guide https://support.ezoic.com/support/solutions/articles/48000453992-using-the-x-forwarded-for-xff-header#anchor5 in order to fix “Error 521: Web server is down issue on my site.”

Within the guide, it is said to simply copy and paste the code below to your theme’s wp-config.php file, but I am not quite sure whre exactly to add the code in my /public_html/wp-config.php file. Code:

/ 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];

}

Would someone be able to advise on my query?

When I have tried to input the code in to the Header.php on my wordpress site, it breaks the site by showing code wording in header.

Thank you in advance.

Hi,

Did you find a solution for this? or anyone? I got the same problem.

Thanks