Prechádzať zdrojové kódy

auto update script executed

Toby Chui 1 rok pred
rodič
commit
70e9d5d384
1 zmenil súbory, kde vykonal 8 pridanie a 3 odobranie
  1. 8 3
      mod/dynamicproxy/dpcore/dpcore.go

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

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