Skip to content

Instantly share code, notes, and snippets.

Created August 1, 2017 17:05
Show Gist options
  • Save anonymous/3b32eb47319c1489211d293212dc0d97 to your computer and use it in GitHub Desktop.
Save anonymous/3b32eb47319c1489211d293212dc0d97 to your computer and use it in GitHub Desktop.
/**
* Handling behind reverse proxy
*/
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['HTTP_X_FORWARDED_PROTO'] == 'https')
$_SERVER['HTTPS']='on';
if (isset($_SERVER['HTTP_X_FORWARDED_HOST'])) {
$_SERVER['HTTP_HOST'] = $_SERVER['HTTP_X_FORWARDED_HOST'];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment