WordPress didn’t make use of the X-Forwarded-For header in my case, so votes/comments were logged with the local IP instead the remote IP. The header field REMOTE_ADDR was set to the local IP of the webserver node behind the reverse proxy.

To get the real remote address of the calling client, you can simply add the following piece of code at the top of wp-config.php:
// ** bw 2012-08-12 wordpress reverse proxy x-forwarded-for ip fix ** //
if(isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
  $xffaddrs = explode(',',$_SERVER['HTTP_X_FORWARDED_FOR']);
  $_SERVER['REMOTE_ADDR'] = $xffaddrs[0];
 }

Benjamin Wiedmann

Benjamin Wiedmann is an IT Professional, Software Developer, Photograph and Musician. Read more...

More Posts - Website

Follow Me:
TwitterLinkedInGoogle Plus


Benjamin Wiedmann

Benjamin Wiedmann is an IT Professional, Software Developer, Photograph and Musician. Read more...

0 Comments

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.