Merge pull request from ArthurHoaro/hotfix/proxy-443

Force HTTPS if the original port is 443 behind a reverse proxy
This commit is contained in:
ArthurHoaro 2017-12-03 12:46:43 +01:00 committed by GitHub
commit 101b935de4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 39 additions and 0 deletions
tests/HttpUtils

View file

@ -186,4 +186,36 @@ class ServerUrlTest extends PHPUnit_Framework_TestCase
)
);
}
/**
* Misconfigured server (see #1022): Proxy HTTP but 443
*/
public function testHttpWithPort433()
{
$this->assertEquals(
'https://host.tld',
server_url(
array(
'HTTPS' => 'Off',
'SERVER_NAME' => 'host.tld',
'SERVER_PORT' => '80',
'HTTP_X_FORWARDED_PROTO' => 'http',
'HTTP_X_FORWARDED_PORT' => '443'
)
)
);
$this->assertEquals(
'https://host.tld',
server_url(
array(
'HTTPS' => 'Off',
'SERVER_NAME' => 'host.tld',
'SERVER_PORT' => '80',
'HTTP_X_FORWARDED_PROTO' => 'https, http',
'HTTP_X_FORWARDED_PORT' => '443, 80'
)
)
);
}
}