From 7ba352f0e58498dacf8aad1c48b56624b795bdcd Mon Sep 17 00:00:00 2001 From: Imre Jonk Date: Mon, 26 Oct 2015 15:02:02 +0100 Subject: [PATCH] Set URLs to https if HTTP X-Forwarded-Proto=https This line changes all URLs to https URLs if the Framadate installation is behind a reverse proxy, and the reverse proxy adds the X-Forwarded-Proto header with the 'https' value. Configuration for nginx: proxy_set_header X-Forwarded-Proto https; This setup is currently used by the Framadate installation of Bits of Freedom (https://kies.bof.nl). --- app/classes/Framadate/Utils.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/classes/Framadate/Utils.php b/app/classes/Framadate/Utils.php index 250528b..d2357ef 100644 --- a/app/classes/Framadate/Utils.php +++ b/app/classes/Framadate/Utils.php @@ -23,7 +23,7 @@ class Utils { * @return string Server name */ public static function get_server_name() { - $scheme = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on') ? 'https' : 'http'; + $scheme = ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on') || (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https')) ? 'https' : 'http'; $port = in_array($_SERVER['SERVER_PORT'], [80, 443]) ? '' : ':' . $_SERVER['SERVER_PORT']; $dirname = dirname($_SERVER['SCRIPT_NAME']); $dirname = $dirname === '\\' ? '/' : $dirname . '/';