Kaynağa Gözat

auto update script executed

Toby Chui 1 yıl önce
ebeveyn
işleme
0508a7a5a4
1 değiştirilmiş dosya ile 5 ekleme ve 3 silme
  1. 5 3
      mod/dynamicproxy/dpcore/dpcore.go

+ 5 - 3
mod/dynamicproxy/dpcore/dpcore.go

@@ -309,9 +309,11 @@ func (p *ReverseProxy) ProxyHTTP(rw http.ResponseWriter, req *http.Request, rrr
 			domainWithoutPort = strings.Split(rrr.ProxyDomain, ":")[0]
 		}
 
-		//Trim away the source headers if exists
-		locationRewrite = strings.TrimPrefix(locationRewrite, "http://"+rrr.ProxyDomain)
-		locationRewrite = strings.TrimPrefix(locationRewrite, "http://"+domainWithoutPort)
+		hostname := req.Header.Get("Host")
+
+		//Replace the forwarded target with expected Host
+		locationRewrite = strings.ReplaceAll(locationRewrite, rrr.ProxyDomain, hostname)
+		locationRewrite = strings.ReplaceAll(locationRewrite, domainWithoutPort, hostname)
 
 		//Custom redirection to this rproxy relative path
 		res.Header.Set("Location", locationRewrite)