From 71d3811da6e5dc320cac17678f5bc63a438054ae Mon Sep 17 00:00:00 2001 From: Werner Fleck Date: Thu, 15 Apr 2021 22:41:28 +0200 Subject: [PATCH] Better HTTPS detection when running behind a reverse proxy --- install.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/install.php b/install.php index df196784..ecac2445 100644 --- a/install.php +++ b/install.php @@ -67,10 +67,12 @@ define('FILENAME', 'index.txt'); // Domain and protocol define('DOMAIN', $_SERVER['HTTP_HOST']); -if (!empty($_SERVER['HTTPS'])) { - define('PROTOCOL', 'https://'); +if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' + || !empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' + || !empty($_SERVER['HTTP_X_FORWARDED_SSL']) && $_SERVER['HTTP_X_FORWARDED_SSL'] == 'on') { + define('PROTOCOL', 'https://'); } else { - define('PROTOCOL', 'http://'); + define('PROTOCOL', 'http://'); } // Base URL