Skip to content
This repository
Browse code

ENHANCEMENT: Ensure that forceSSL and protocol detection respects the…

… X-Forwarded-Protocol header.
  • Loading branch information...
commit 2648411829bd8a851df78c63f5f8f763c70a63bc 1 parent d261f44
Sam Minnée authored February 03, 2012

Showing 1 changed file with 2 additions and 1 deletion. Show diff stats Hide diff stats

  1. 3  control/Director.php
3  control/Director.php
@@ -376,6 +376,7 @@ static function protocolAndHost() {
376 376
 	 * @return String
377 377
 	 */
378 378
 	static function protocol() {
  379
+		if(isset($_SERVER['HTTP_X_FORWARDED_PROTOCOL']) && strtolower($_SERVER['HTTP_X_FORWARDED_PROTOCOL']) == 'https') return "https://";
379 380
 		return (isset($_SERVER['SSL']) || (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off')) ? 'https://' : 'http://';
380 381
 	}
381 382
 
@@ -652,7 +653,7 @@ static function forceSSL($patterns = null) {
652 653
 			$matched = true;
653 654
 		}
654 655
 
655  
-		if($matched && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] == 'off')) {
  656
+		if($matched && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] == 'off') && !(isset($_SERVER['HTTP_X_FORWARDED_PROTOCOL']) && strtolower($_SERVER['HTTP_X_FORWARDED_PROTOCOL']) == 'https')) {
656 657
 			$destURL = str_replace('http:', 'https:', Director::absoluteURL($_SERVER['REQUEST_URI']));
657 658
 
658 659
 			// This coupling to SapphireTest is necessary to test the destination URL and to not interfere with tests

0 notes on commit 2648411

Please sign in to comment.
Something went wrong with that request. Please try again.