|
@@ -2,6 +2,7 @@ package dpcore
|
|
|
|
|
|
import (
|
|
|
"errors"
|
|
|
+ "fmt"
|
|
|
"io"
|
|
|
"log"
|
|
|
"net"
|
|
@@ -348,9 +349,13 @@ func (p *ReverseProxy) ProxyHTTP(rw http.ResponseWriter, req *http.Request, rrr
|
|
|
domainWithoutPort = strings.Split(rrr.ProxyDomain, ":")[0]
|
|
|
}
|
|
|
|
|
|
- //Replace the forwarded target with expected Host
|
|
|
- locationRewrite = strings.ReplaceAll(locationRewrite, rrr.ProxyDomain, rrr.OriginalHost)
|
|
|
- locationRewrite = strings.ReplaceAll(locationRewrite, domainWithoutPort, rrr.OriginalHost)
|
|
|
+ if strings.HasPrefix(originLocation, "http://") || strings.HasPrefix(originLocation, "https://") {
|
|
|
+ //Full path
|
|
|
+ //Replace the forwarded target with expected Host
|
|
|
+ fmt.Println(rrr.ProxyDomain, domainWithoutPort, rrr.OriginalHost)
|
|
|
+ locationRewrite = strings.ReplaceAll(locationRewrite, rrr.ProxyDomain, rrr.OriginalHost)
|
|
|
+ locationRewrite = strings.ReplaceAll(locationRewrite, domainWithoutPort, rrr.OriginalHost)
|
|
|
+ }
|
|
|
|
|
|
//Custom redirection to this rproxy relative path
|
|
|
res.Header.Set("Location", locationRewrite)
|