From 2ac26f6aa48b4ddcf27a600efb7493e8f5ea8430 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E7=A5=A5=E8=B6=85?= Date: Sun, 5 Dec 2021 09:30:45 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9B=9E=E6=BA=90=E4=B8=BB=E6=9C=BA=E5=90=8D?= =?UTF-8?q?=E4=B8=BA=E2=80=9C=E8=B7=9F=E9=9A=8F=E6=BA=90=E7=AB=99=E2=80=9D?= =?UTF-8?q?=E6=97=B6=EF=BC=8C=E8=8E=B7=E5=BE=97=E7=9A=84=E6=BA=90=E7=AB=99?= =?UTF-8?q?=E4=B8=BB=E6=9C=BA=E5=90=8D=E5=8E=BB=E9=99=A4=E5=B8=B8=E8=A7=84?= =?UTF-8?q?=E7=AB=AF=E5=8F=A380=E5=92=8C443?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/nodes/http_request_reverse_proxy.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/internal/nodes/http_request_reverse_proxy.go b/internal/nodes/http_request_reverse_proxy.go index 6940835..47a362a 100644 --- a/internal/nodes/http_request_reverse_proxy.go +++ b/internal/nodes/http_request_reverse_proxy.go @@ -117,7 +117,15 @@ func (this *HTTPRequest) doReverseProxy() { } this.RawReq.URL.Host = this.RawReq.Host } else if this.reverseProxy.RequestHostType == serverconfigs.RequestHostTypeOrigin { - this.RawReq.Host = originAddr + // 源站主机名 + var hostname = originAddr + if origin.Addr.Protocol.IsHTTPFamily() { + hostname = strings.TrimSuffix(hostname, ":80") + } else if origin.Addr.Protocol.IsHTTPSFamily() { + hostname = strings.TrimSuffix(hostname, ":443") + } + + this.RawReq.Host = hostname this.RawReq.URL.Host = this.RawReq.Host } else { this.RawReq.URL.Host = this.Host