Forráskód Böngészése

auto update script executed

Toby Chui 1 éve
szülő
commit
5989df32d7
2 módosított fájl, 32 hozzáadás és 0 törlés
  1. 9 0
      mod/dynamicproxy/dpcore/utils.go
  2. 23 0
      test/redirect (bug #39)/main.go

+ 9 - 0
mod/dynamicproxy/dpcore/utils.go

@@ -21,6 +21,15 @@ func replaceLocationHost(urlString string, rrr *ResponseRewriteRuleSet, useTLS b
 		u.Scheme = "http"
 	}
 
+	//Issue #39: Check if it is location target match the proxying domain
+	//E.g. Proxy config: blog.example.com -> example.com/blog
+	//Check if it is actually redirecting to example.com instead of a new domain
+	//like news.example.com.
+	if rrr.ProxyDomain != u.Host {
+		//New location domain not matching proxy target domain.
+		//Do not modify location header
+		return urlString, nil
+	}
 	u.Host = rrr.OriginalHost
 
 	if strings.Contains(rrr.ProxyDomain, "/") {

+ 23 - 0
test/redirect (bug #39)/main.go

@@ -0,0 +1,23 @@
+package main
+
+import (
+	"fmt"
+	"net/http"
+)
+
+func redirectToImuslab(w http.ResponseWriter, r *http.Request) {
+	fmt.Println(r.RequestURI)
+	w.Header().Set("Location", "https://imuslab.com")
+	w.WriteHeader(http.StatusTemporaryRedirect)
+	w.Write([]byte("Redirecting to imuslab"))
+}
+
+func listindex(w http.ResponseWriter, r *http.Request) {
+	w.Write([]byte("Hello World"))
+}
+
+func main() {
+	http.HandleFunc("/test", redirectToImuslab)
+	fmt.Println("Listeing on :8080")
+	http.ListenAndServe(":8080", nil)
+}