Skip to content

Instantly share code, notes, and snippets.

@thiagomgo
Created June 29, 2021 22:21
Show Gist options
  • Save thiagomgo/d12b25f98d55d745b2324800425941e2 to your computer and use it in GitHub Desktop.
Save thiagomgo/d12b25f98d55d745b2324800425941e2 to your computer and use it in GitHub Desktop.
Fix broken SSL access
<?php
if ((isset($_ENV["HTTPS"]) && ("on" == $_ENV["HTTPS"]))
|| (isset($_SERVER["HTTP_X_FORWARDED_SSL"]) && (strpos($_SERVER["HTTP_X_FORWARDED_SSL"], "1") !== false))
|| (isset($_SERVER["HTTP_X_FORWARDED_SSL"]) && (strpos($_SERVER["HTTP_X_FORWARDED_SSL"], "on") !== false))
|| (isset($_SERVER["HTTP_CF_VISITOR"]) && (strpos($_SERVER["HTTP_CF_VISITOR"], "https") !== false))
|| (isset($_SERVER["HTTP_CLOUDFRONT_FORWARDED_PROTO"]) && (strpos($_SERVER["HTTP_CLOUDFRONT_FORWARDED_PROTO"], "https") !== false))
|| (isset($_SERVER["HTTP_X_FORWARDED_PROTO"]) && (strpos($_SERVER["HTTP_X_FORWARDED_PROTO"], "https") !== false))
) {
$_SERVER["HTTPS"] = "on";
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment