diff --git a/control/Director.php b/control/Director.php index a0833df61..5b173d1cb 100644 --- a/control/Director.php +++ b/control/Director.php @@ -376,6 +376,7 @@ class Director { * @return String */ static function protocol() { + if(isset($_SERVER['HTTP_X_FORWARDED_PROTOCOL']) && strtolower($_SERVER['HTTP_X_FORWARDED_PROTOCOL']) == 'https') return "https://"; return (isset($_SERVER['SSL']) || (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off')) ? 'https://' : 'http://'; } @@ -652,7 +653,7 @@ class Director { $matched = true; } - if($matched && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] == 'off')) { + if($matched && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] == 'off') && !(isset($_SERVER['HTTP_X_FORWARDED_PROTOCOL']) && strtolower($_SERVER['HTTP_X_FORWARDED_PROTOCOL']) == 'https')) { $destURL = str_replace('http:', 'https:', Director::absoluteURL($_SERVER['REQUEST_URI'])); // This coupling to SapphireTest is necessary to test the destination URL and to not interfere with tests