Fix protocol detection when behind HTTPS proxy (#80)

This commit is contained in:
Maxime Mérian 2019-02-21 15:27:44 +01:00 committed by Bartek Fabiszewski
parent 2f566430f7
commit 53c48378b8

View File

@ -116,6 +116,10 @@
*/
public static function getBaseUrl() {
$proto = (!isset($_SERVER["HTTPS"]) || $_SERVER["HTTPS"] == "" || $_SERVER["HTTPS"] == "off") ? "http://" : "https://";
// Check if we are behind an https proxy
if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https') {
$proto = 'https://';
}
$host = isset($_SERVER["HTTP_HOST"]) ? $_SERVER["HTTP_HOST"] : "";
if (realpath($_SERVER["SCRIPT_FILENAME"])) {
$scriptPath = substr(dirname(realpath($_SERVER["SCRIPT_FILENAME"])), strlen(ROOT_DIR));
@ -131,4 +135,4 @@
}
?>
?>