Skip to content
This repository has been archived by the owner on Jun 11, 2024. It is now read-only.

Commit

Permalink
Fix handling of protocols forwarded by proxy. Fix #313.
Browse files Browse the repository at this point in the history
  • Loading branch information
white-gecko committed Nov 18, 2014
1 parent b013150 commit f14669a
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion application/Bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,16 @@ public function _initConfig()

// set path variables
$rewriteBase = substr($_SERVER['PHP_SELF'], 0, strpos($_SERVER['PHP_SELF'], BOOTSTRAP_FILE));
$protocol = (isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on') ? 'https' : 'http';

// set protocol and read headers send by proxies
$protocol = 'http';
if (isset($_SERVER['X-Forwarded-Protocol'])) {
$protocol = strtolower($_SERVER['X-Forwarded-Protocol']);
} else if (isset($_SERVER['HTTP_X_FORWARDED_PROTO'])) {
$protocol = strtolower($_SERVER['HTTP_X_FORWARDED_PROTO']);
} else if (isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on') {
$protocol = 'https';
}

if (isset($_SERVER['HTTP_HOST'])) {
$httpHost = $_SERVER['HTTP_HOST'];
Expand Down

0 comments on commit f14669a

Please sign in to comment.