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
  • Save codehead/5170666d0755d5bd3312 to your computer and use it in GitHub Desktop.
Save codehead/5170666d0755d5bd3312 to your computer and use it in GitHub Desktop.

Revisions

  1. codehead revised this gist Apr 27, 2015. 1 changed file with 5 additions and 4 deletions.
    9 changes: 5 additions & 4 deletions wp-config.php
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,8 @@
    // 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];
    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];
    }
    }
  2. @ryanjbonnell ryanjbonnell created this gist Mar 12, 2014.
    7 changes: 7 additions & 0 deletions wp-config.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,7 @@
    // 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];
    }