From e7ec32ad07883451f2448c620fcbcc7b59a9befc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E6=99=AF=E7=AB=8B?= Date: Wed, 14 Aug 2024 10:22:37 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BC=98=E5=8C=96=20Worker=20Host=20?= =?UTF-8?q?=E6=8E=A5=E6=94=B6=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugin/think-plugs-worker/src/support/ThinkRequest.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/plugin/think-plugs-worker/src/support/ThinkRequest.php b/plugin/think-plugs-worker/src/support/ThinkRequest.php index 37a8e4ea1..93aedb1b0 100644 --- a/plugin/think-plugs-worker/src/support/ThinkRequest.php +++ b/plugin/think-plugs-worker/src/support/ThinkRequest.php @@ -66,12 +66,14 @@ class ThinkRequest extends Request $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)))) { $port = strpos($this->host, ':') !== false ? explode(':', $this->host)[1] : $connection->getRemotePort(); } - // 如果是正常端口,不需要在 host 表示出来 + + // 如果是正常端口,不需要在 host 表示端口 if (strpos($this->host, ':') !== false && in_array($port, [80, 443])) { $this->host = strstr($this->host, ':', true); }