回源主机名为“跟随源站”时,获得的源站主机名去除常规端口80和443

This commit is contained in:
刘祥超
2021-12-05 09:30:45 +08:00
parent d9aac44ea3
commit 2ac26f6aa4

View File

@@ -117,7 +117,15 @@ func (this *HTTPRequest) doReverseProxy() {
} }
this.RawReq.URL.Host = this.RawReq.Host this.RawReq.URL.Host = this.RawReq.Host
} else if this.reverseProxy.RequestHostType == serverconfigs.RequestHostTypeOrigin { } 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 this.RawReq.URL.Host = this.RawReq.Host
} else { } else {
this.RawReq.URL.Host = this.Host this.RawReq.URL.Host = this.Host