|
@@ -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)
|