Bug #5850

New server - $_SERVER['REMOTE_ADDR'] using private IP instead of user IP

Added by Raymond Hoh over 5 years ago. Updated over 5 years ago.

Priority name:
Category name:
Target version:
Start date:
Due date:
% Done:


Estimated time:


I was testing bbPress on the new server and the IP address that is logged for each forum post uses a private IP address by the server, instead of the user's IP.

The issue is bbPress uses $_SERVER['REMOTE_ADDR'] to attempt to grab the user's IP. However, the load balancer uses $_SERVER['HTTP_X_FORWARDED_FOR'].

I'm thinking we could override REMOTE_ADDR with HTTP_X_FORWARDED_FOR manually in wp-config.php as recommend in this WP Trac ticket:


#1 Updated by Boone Gorges over 5 years ago

Yup, this seems fine with me. Not something I would support introducing into WP core, but fine for the Commons :)

#2 Updated by Raymond Hoh over 5 years ago

Boone, I've committed the change on the server (commit 90e7f9a), but haven't pushed it to Github because I haven't pulled the latest changes to master branch on the server yet.

Wasn't sure what the release strategy was for 1.9.22, so thought I'd touch base with you before I did a git pull on the server.

#3 Updated by Boone Gorges over 5 years ago

Thanks, Ray. The commit looks good.

Since it's looking like the regularly scheduled 1.9.22 release will go out before the server migration, please do keep the 1.9.x and master branches so that they continue to work properly on the existing server. That said, your HTTP_X_FORWARDED_FOR check should mean that the commit does nothing at all on the existing server (unless someone's doing something nefarious), so I don't see any harm in putting it into the mainline branch.

#4 Updated by Raymond Hoh over 5 years ago

Actually, I'm going to revert the commit and move the code to cac-env-config.php since this code is specific to the load balancer only.

#5 Updated by Raymond Hoh over 5 years ago

  • Status changed from New to Resolved

Marking as resolved.

Also available in: Atom PDF