Skip to content

Instantly share code, notes, and snippets.

@fprochazka
Created July 19, 2015 12:32
Show Gist options
  • Star 9 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save fprochazka/648eb6b0fcca406a16cd to your computer and use it in GitHub Desktop.
Save fprochazka/648eb6b0fcca406a16cd to your computer and use it in GitHub Desktop.
<?php
// hack for https proxies
if (isset($_SERVER['HTTP_X_FORWARDED_PROTO'])) {
if ($_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https' && isset($_SERVER['SERVER_PORT']) && in_array($_SERVER['SERVER_PORT'], [80, 82])) { // https over proxy
$_SERVER['HTTPS'] = 'On';
$_SERVER['SERVER_PORT'] = 443;
} elseif ($_SERVER['HTTP_X_FORWARDED_PROTO'] === 'http' && isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] == 80) { // http over proxy
$_SERVER['HTTPS'] = 'Off';
$_SERVER['SERVER_PORT'] = 80;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment