mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
BUG Add support for X-Forwarded-Proto checking SSL (Fixes #1416)
De-facto standard for identifying the originating protocol of an HTTP request through a reverse proxy or load balancer. http://www.geekisp.com/faq/6_65_en.html
This commit is contained in:
parent
e7266535c5
commit
c61f6540fb
@ -459,7 +459,7 @@ class Director implements TemplateGlobalProvider {
|
|||||||
*/
|
*/
|
||||||
public static function protocol() {
|
public static function protocol() {
|
||||||
return (self::is_https()) ? 'https://' : 'http://';
|
return (self::is_https()) ? 'https://' : 'http://';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return whether the site is running as under HTTPS.
|
* Return whether the site is running as under HTTPS.
|
||||||
@ -469,18 +469,23 @@ class Director implements TemplateGlobalProvider {
|
|||||||
public static function is_https() {
|
public static function is_https() {
|
||||||
if ($protocol = Config::inst()->get('Director', 'alternate_protocol')) {
|
if ($protocol = Config::inst()->get('Director', 'alternate_protocol')) {
|
||||||
return $protocol == 'https';
|
return $protocol == 'https';
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isset($_SERVER['HTTP_X_FORWARDED_PROTOCOL'])) {
|
if(isset($_SERVER['HTTP_X_FORWARDED_PROTOCOL'])) {
|
||||||
if(strtolower($_SERVER['HTTP_X_FORWARDED_PROTOCOL']) == 'https') {
|
if(strtolower($_SERVER['HTTP_X_FORWARDED_PROTOCOL']) == 'https') {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(isset($_SERVER['X-Forwarded-Proto'])) {
|
||||||
|
if(strtolower($_SERVER['X-Forwarded-Proto']) == "https") {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if((!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off')) {
|
if((!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off')) {
|
||||||
return true;
|
return true;
|
||||||
}
|
} else if(isset($_SERVER['SSL'])) {
|
||||||
else if(isset($_SERVER['SSL'])) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -507,11 +512,11 @@ class Director implements TemplateGlobalProvider {
|
|||||||
$baseURL = '/';
|
$baseURL = '/';
|
||||||
} else {
|
} else {
|
||||||
$baseURL = $base . '/';
|
$baseURL = $base . '/';
|
||||||
}
|
}
|
||||||
|
|
||||||
if(defined('BASE_SCRIPT_URL')) {
|
if(defined('BASE_SCRIPT_URL')) {
|
||||||
return $baseURL . BASE_SCRIPT_URL;
|
return $baseURL . BASE_SCRIPT_URL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $baseURL;
|
return $baseURL;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user