diff options
author | Fanch <fanch-github@qth.fr> | 2015-09-01 13:37:04 +0200 |
---|---|---|
committer | VirtualTam <virtualtam@flibidi.net> | 2015-09-13 21:17:01 +0200 |
commit | 7b114771d337af3bfd51d8fda1e8f2fd5b39535d (patch) | |
tree | 897fa51315d233af261dd7a13c011f46ff7b4816 /index.php | |
parent | ce47a75864d7d398a68705df67da2ae00ca89eca (diff) | |
download | Shaarli-7b114771d337af3bfd51d8fda1e8f2fd5b39535d.tar.gz Shaarli-7b114771d337af3bfd51d8fda1e8f2fd5b39535d.tar.zst Shaarli-7b114771d337af3bfd51d8fda1e8f2fd5b39535d.zip |
SSL detection: add support for `X-Forwarded-Proto`
Duplicates #332
See:
- RFC 7239 - Forwarded HTTP Extension
http://www.ietf.org/rfc/rfc7239.txt
- RFC 6238 - Deprecating the "X-" Prefix and Similar Constructs in Application Protocols
http://www.ietf.org/rfc/rfc6648.txt
- StackOverflow - Custom HTTP headers: naming conventions
http://stackoverflow.com/a/3561399
Diffstat (limited to 'index.php')
-rwxr-xr-x | index.php | 2 |
1 files changed, 1 insertions, 1 deletions
@@ -463,7 +463,7 @@ if (isset($_POST['login'])) | |||
463 | // You can append $_SERVER['SCRIPT_NAME'] to get the current script URL. | 463 | // You can append $_SERVER['SCRIPT_NAME'] to get the current script URL. |
464 | function serverUrl() | 464 | function serverUrl() |
465 | { | 465 | { |
466 | $https = (!empty($_SERVER['HTTPS']) && (strtolower($_SERVER['HTTPS'])=='on')) || $_SERVER["SERVER_PORT"]=='443'; // HTTPS detection. | 466 | $https = (!empty($_SERVER['HTTPS']) && (strtolower($_SERVER['HTTPS'])=='on')) || $_SERVER["SERVER_PORT"]=='443' || (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https'); // HTTPS detection. |
467 | $serverport = ($_SERVER["SERVER_PORT"]=='80' || ($https && $_SERVER["SERVER_PORT"]=='443') ? '' : ':'.$_SERVER["SERVER_PORT"]); | 467 | $serverport = ($_SERVER["SERVER_PORT"]=='80' || ($https && $_SERVER["SERVER_PORT"]=='443') ? '' : ':'.$_SERVER["SERVER_PORT"]); |
468 | return 'http'.($https?'s':'').'://'.$_SERVER['SERVER_NAME'].$serverport; | 468 | return 'http'.($https?'s':'').'://'.$_SERVER['SERVER_NAME'].$serverport; |
469 | } | 469 | } |