fix error when use different protocol between reverse proxy and backend.

This commit is contained in:
renothing 2018-10-28 03:48:57 +08:00
parent 235888cc3e
commit 1e7e7e7997

View File

@ -237,7 +237,9 @@ class Typecho_Request
*/
public static function isSecure()
{
return (!empty($_SERVER['HTTPS']) && 'off' != strtolower($_SERVER['HTTPS']))
return (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && !strcasecmp('https', $_SERVER['HTTP_X_FORWARDED_PROTO']))
|| (!empty($_SERVER['HTTP_X_FORWARDED_PORT']) && 443 == $_SERVER['HTTP_X_FORWARDED_PORT'])
|| (!empty($_SERVER['HTTPS']) && 'off' != strtolower($_SERVER['HTTPS']))
|| (!empty($_SERVER['SERVER_PORT']) && 443 == $_SERVER['SERVER_PORT'])
|| (defined('__TYPECHO_SECURE__') && __TYPECHO_SECURE__);
}