Browse Source

Fix #18518: Add support for ngrok’s `X-Original-Host` header

tags/2.0.41
Brandon Kelly 4 years ago committed by GitHub
parent
commit
f935065bca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      framework/CHANGELOG.md
  2. 5
      framework/web/Request.php

1
framework/CHANGELOG.md

@ -18,6 +18,7 @@ Yii Framework 2 Change Log
- Enh #18487: Allow creating URLs for non-GET-verb rules (bizley) - Enh #18487: Allow creating URLs for non-GET-verb rules (bizley)
- Bug #8750: Fix MySQL support when running in `ANSI`/`ANSI_QUOTES` modes (brandonkelly) - Bug #8750: Fix MySQL support when running in `ANSI`/`ANSI_QUOTES` modes (brandonkelly)
- Bug #18505: Fixed `yii\helpers\ArrayHelper::getValue()` for ArrayAccess objects with explicitly defined properties (samdark) - Bug #18505: Fixed `yii\helpers\ArrayHelper::getValue()` for ArrayAccess objects with explicitly defined properties (samdark)
- Enh #18518: Add support for ngrok’s `X-Original-Host` header (brandonkelly)
2.0.40 December 23, 2020 2.0.40 December 23, 2020

5
framework/web/Request.php

@ -231,6 +231,9 @@ class Request extends \yii\base\Request
// Microsoft: // Microsoft:
'Front-End-Https', 'Front-End-Https',
'X-Rewrite-Url', 'X-Rewrite-Url',
// ngrok:
'X-Original-Host',
]; ];
/** /**
* @var string[] List of headers where proxies store the real client IP. * @var string[] List of headers where proxies store the real client IP.
@ -744,6 +747,8 @@ class Request extends \yii\base\Request
$this->_hostInfo = $http . '://' . $this->getSecureForwardedHeaderTrustedPart('host'); $this->_hostInfo = $http . '://' . $this->getSecureForwardedHeaderTrustedPart('host');
} elseif ($this->headers->has('X-Forwarded-Host')) { } elseif ($this->headers->has('X-Forwarded-Host')) {
$this->_hostInfo = $http . '://' . trim(explode(',', $this->headers->get('X-Forwarded-Host'))[0]); $this->_hostInfo = $http . '://' . trim(explode(',', $this->headers->get('X-Forwarded-Host'))[0]);
} elseif ($this->headers->has('X-Original-Host')) {
$this->_hostInfo = $http . '://' . trim(explode(',', $this->headers->get('X-Original-Host'))[0]);
} elseif ($this->headers->has('Host')) { } elseif ($this->headers->has('Host')) {
$this->_hostInfo = $http . '://' . $this->headers->get('Host'); $this->_hostInfo = $http . '://' . $this->headers->get('Host');
} elseif (isset($_SERVER['SERVER_NAME'])) { } elseif (isset($_SERVER['SERVER_NAME'])) {

Loading…
Cancel
Save