Handle HTTP header "X-Forwarded-Proto: https"

This commit is contained in:
Frederic Guillot 2017-06-04 17:45:56 -04:00
parent c7341829e1
commit 553a5a700d

View File

@ -54,6 +54,7 @@ function get_current_base_url()
if (strpos($_SERVER['HTTP_HOST'], ':') === false) { if (strpos($_SERVER['HTTP_HOST'], ':') === false) {
$url .= $_SERVER['SERVER_PORT'] == 80 || $_SERVER['SERVER_PORT'] == 443 ? '' : ':'.$_SERVER['SERVER_PORT']; $url .= $_SERVER['SERVER_PORT'] == 80 || $_SERVER['SERVER_PORT'] == 443 ? '' : ':'.$_SERVER['SERVER_PORT'];
} }
$url .= str_replace('\\', '/', dirname($_SERVER['PHP_SELF'])) !== '/' ? str_replace('\\', '/', dirname($_SERVER['PHP_SELF'])).'/' : '/'; $url .= str_replace('\\', '/', dirname($_SERVER['PHP_SELF'])) !== '/' ? str_replace('\\', '/', dirname($_SERVER['PHP_SELF'])).'/' : '/';
return $url; return $url;
@ -62,7 +63,7 @@ function get_current_base_url()
function is_secure_connection() function is_secure_connection()
{ {
return ! empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off'; return (! empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') || (! empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https');
} }
function write_debug_file() { function write_debug_file() {