Skip to content

Instantly share code, notes, and snippets.

@grizmin
Created May 17, 2018 11:14
Show Gist options
  • Save grizmin/becfc0bc640402ceef7f7551468e9f83 to your computer and use it in GitHub Desktop.
Save grizmin/becfc0bc640402ceef7f7551468e9f83 to your computer and use it in GitHub Desktop.
WordPress behind HTTPS reverse proxy
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