From 53c48378b8b7fae25f2537c5b9d8fa66b7cfc685 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maxime=20M=C3=A9rian?= Date: Thu, 21 Feb 2019 15:27:44 +0100 Subject: [PATCH] Fix protocol detection when behind HTTPS proxy (#80) --- helpers/utils.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/helpers/utils.php b/helpers/utils.php index c29dbe0..91791f8 100644 --- a/helpers/utils.php +++ b/helpers/utils.php @@ -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 @@ } -?> \ No newline at end of file +?>