Improve https detection

pull/2487/head
jmontoyaa 8 years ago
parent 9b58903a87
commit feec1bccee
  1. 18
      main/inc/lib/api.lib.php

@ -7730,7 +7730,23 @@ function api_get_firstpage_parameter()
*/
function api_is_https()
{
return (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off');
if (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) &&
$_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' || !empty($_configuration['force_https_forwarded_proto'])
) {
$protocol = 'https';
} else {
if (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') {
$protocol = 'https';
} else {
$protocol = 'http';
// last chance
if (!empty($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] == 443) {
$protocol = 'https';
}
}
}
return $protocol === 'https';
}
/**

Loading…
Cancel
Save