support for forwarded proto/port in Server.php (#2343)

pull/2345/head
Mike Rosack 2018-12-13 09:24:32 -06:00 committed by Isaac Connor
parent 882c4e2ea6
commit 567b60ffa7
1 changed files with 11 additions and 1 deletions

View File

@ -62,7 +62,12 @@ class Server {
if ( isset($this->{'Protocol'}) and ( $this->{'Protocol'} != '' ) ) {
return $this->{'Protocol'};
}
return (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443) ? 'https' : 'http';
return (
( isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' )
or
( isset($_SERVER['HTTP_X_FORWARDED_PROTO']) and ( $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' ) )
) ? 'https' : 'http';
}
public function Port( $new = '' ) {
@ -72,6 +77,11 @@ class Server {
if ( isset($this->{'Port'}) and $this->{'Port'} ) {
return $this->{'Port'};
}
if ( isset($_SERVER['HTTP_X_FORWARDED_PORT']) ) {
return $_SERVER['HTTP_X_FORWARDED_PORT'];
}
return $_SERVER['SERVER_PORT'];
}