自动替换Location中的地址时检查域名是否为当前域名

This commit is contained in:
刘祥超
2022-05-04 10:48:14 +08:00
parent d6ceccc52e
commit e88eda56f5

View File

@@ -283,7 +283,7 @@ func (this *HTTPRequest) doReverseProxy() {
var locationHeader = resp.Header.Get("Location")
if len(locationHeader) > 0 {
locationURL, err := url.Parse(locationHeader)
if err == nil && (locationURL.Host == originAddr || strings.HasPrefix(originAddr, locationURL.Host+":")) {
if err == nil && locationURL.Host != this.ReqHost && (locationURL.Host == originAddr || strings.HasPrefix(originAddr, locationURL.Host+":")) {
locationURL.Host = this.ReqHost
if this.IsHTTP {
locationURL.Scheme = "http"