Fix incorrect client IP for WordPress behind reverse proxy

If you are running WordPress behind a reverse proxy, you will need to add the below code to the top of `wp-config.php`:
{{{
// Alter `REMOTE_ADDR` header to `HTTP_X_FORWARDED_FOR` if it exists.
if($_SERVER[‘HTTP_X_FORWARDED_FOR’]) {
$xaddr = explode(‘,’,$_SERVER[‘HTTP_X_FORWARDED_FOR’]);
$_SERVER[‘REMOTE_ADDR’] = $xaddr[0];
}
}}}


Posted

in

by

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *