Skip to content

Instantly share code, notes, and snippets.

@codehead
Forked from ryanjbonnell/wp-config.php
Last active August 29, 2015 14:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codehead/5170666d0755d5bd3312 to your computer and use it in GitHub Desktop.
Save codehead/5170666d0755d5bd3312 to your computer and use it in GitHub Desktop.
// Use X-Forwarded-For HTTP Header to Get Visitor's Real IP Address
if($_SERVER['REMOTE_ADDR']=="10.1.1.1") { // Known reverse proxy
if ( isset( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) { // Known header
$http_x_headers = explode( ',', $_SERVER['HTTP_X_FORWARDED_FOR'] );
$_SERVER['REMOTE_ADDR'] = $http_x_headers[0];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment