Created
May 17, 2018 11:14
-
-
Save grizmin/becfc0bc640402ceef7f7551468e9f83 to your computer and use it in GitHub Desktop.
WordPress behind HTTPS reverse proxy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) { | |
$ips = explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']); | |
$_SERVER['REMOTE_ADDR'] = $ips[0]; | |
} | |
// If we're behind a proxy server and using HTTPS, we need to alert Wordpress of that fact | |
// see also http://codex.wordpress.org/Administration_Over_SSL#Using_a_Reverse_Proxy | |
if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') { | |
$_SERVER['HTTPS'] = 'on'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment