Re-added SSL off-loading that was lost with Grav v1.4.0 merge #1888

This commit is contained in:
Andy Miller
2018-05-31 14:05:33 -06:00
parent 9eded2ef39
commit 27a9390ec7
2 changed files with 23 additions and 3 deletions

View File

@@ -1,3 +1,10 @@
# v1.4.6
## mm/dd/2018
1. [](#improved)
* Manually re-added the improved SSL off-loading that was lost with Grav v1.4.0 merge [#1888](https://github.com/getgrav/grav/pull/1888)
# v1.4.5
## 05/15/2018

View File

@@ -1119,8 +1119,12 @@ class Uri
protected function createFromEnvironment(array $env)
{
// Build scheme.
if (isset($env['REQUEST_SCHEME'])) {
$this->scheme = $env['REQUEST_SCHEME'];
if (isset($env['HTTP_X_FORWARDED_PROTO'])) {
$this->scheme = $env['HTTP_X_FORWARDED_PROTO'];
} elseif (isset($env['X-FORWARDED-PROTO'])) {
$this->scheme = $env['X-FORWARDED-PROTO'];
} elseif (isset($env['REQUEST_SCHEME'])) {
$this->scheme = $env['REQUEST_SCHEME'];
} else {
$https = isset($env['HTTPS']) ? $env['HTTPS'] : '';
$this->scheme = (empty($https) || strtolower($https) === 'off') ? 'http' : 'https';
@@ -1143,7 +1147,16 @@ class Uri
$this->host = $this->validateHostname($hostname) ? $hostname : 'unknown';
// Build port.
$this->port = isset($env['SERVER_PORT']) ? (int)$env['SERVER_PORT'] : null;
if (isset($env['HTTP_X_FORWARDED_PORT'])) {
$this->port = (int)$env['HTTP_X_FORWARDED_PORT'];
} elseif (isset($env['X-FORWARDED-PORT'])) {
$this->port = (int)$env['X-FORWARDED-PORT'];
} elseif (isset($env['SERVER_PORT'])) {
$this->port = (int)$env['SERVER_PORT'];
} else {
$this->port = null;
}
if ($this->hasStandardPort()) {
$this->port = null;
}