mirror of
https://gitee.com/zoujingli/ThinkAdmin.git
synced 2026-06-11 13:58:11 +08:00
fix: 优化 Worker Host 接收逻辑
This commit is contained in:
parent
04f82f46e9
commit
e7ec32ad07
@ -66,12 +66,14 @@ class ThinkRequest extends Request
|
|||||||
$this->realIP = $this->header['x-real-ip'] ?? ($this->header['x-forwarded-for'] ?? $connection->getRemoteIp());
|
$this->realIP = $this->header['x-real-ip'] ?? ($this->header['x-forwarded-for'] ?? $connection->getRemoteIp());
|
||||||
|
|
||||||
// 请求服务器的域名处理
|
// 请求服务器的域名处理
|
||||||
$this->host = $this->header['x-host'] ?? ($this->header['x-requested-host'] ?? ($this->header['host'] ?? $request->host()));
|
$this->host = $this->header['x-host'] ?? ($this->header['x-requested-host'] ?? ($this->header['remote-host'] ?? ($this->header['host'] ?? $request->host())));
|
||||||
|
|
||||||
// 请求服务器的端口处理
|
// 请求服务器的端口处理
|
||||||
if (!is_numeric($port = $this->header['x-port'] ?? ($this->header['x-requested-port'] ?? ($this->header['port'] ?? null)))) {
|
if (!is_numeric($port = $this->header['x-port'] ?? ($this->header['x-requested-port'] ?? ($this->header['port'] ?? null)))) {
|
||||||
$port = strpos($this->host, ':') !== false ? explode(':', $this->host)[1] : $connection->getRemotePort();
|
$port = strpos($this->host, ':') !== false ? explode(':', $this->host)[1] : $connection->getRemotePort();
|
||||||
}
|
}
|
||||||
// 如果是正常端口,不需要在 host 表示出来
|
|
||||||
|
// 如果是正常端口,不需要在 host 表示端口
|
||||||
if (strpos($this->host, ':') !== false && in_array($port, [80, 443])) {
|
if (strpos($this->host, ':') !== false && in_array($port, [80, 443])) {
|
||||||
$this->host = strstr($this->host, ':', true);
|
$this->host = strstr($this->host, ':', true);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user