diff --git a/internal/nodes/http_request.go b/internal/nodes/http_request.go index d742596..81aa2d2 100644 --- a/internal/nodes/http_request.go +++ b/internal/nodes/http_request.go @@ -144,9 +144,10 @@ func (this *HTTPRequest) Do() { // 自动跳转到HTTPS if this.IsHTTP && this.web.RedirectToHttps != nil && this.web.RedirectToHttps.IsOn { - this.doRedirectToHTTPS(this.web.RedirectToHttps) - this.doEnd() - return + if this.doRedirectToHTTPS(this.web.RedirectToHttps) { + this.doEnd() + return + } } // Gzip diff --git a/internal/nodes/http_request_redirect_https.go b/internal/nodes/http_request_redirect_https.go index 19ca9b9..5b274d3 100644 --- a/internal/nodes/http_request_redirect_https.go +++ b/internal/nodes/http_request_redirect_https.go @@ -7,9 +7,14 @@ import ( "strings" ) -func (this *HTTPRequest) doRedirectToHTTPS(redirectToHTTPSConfig *serverconfigs.HTTPRedirectToHTTPSConfig) { +func (this *HTTPRequest) doRedirectToHTTPS(redirectToHTTPSConfig *serverconfigs.HTTPRedirectToHTTPSConfig) (shouldBreak bool) { host := this.RawReq.Host + // 检查域名是否匹配 + if !redirectToHTTPSConfig.MatchDomain(host) { + return false + } + if len(redirectToHTTPSConfig.Host) > 0 { if redirectToHTTPSConfig.Port > 0 && redirectToHTTPSConfig.Port != 443 { host = redirectToHTTPSConfig.Host + ":" + strconv.Itoa(redirectToHTTPSConfig.Port) @@ -38,4 +43,6 @@ func (this *HTTPRequest) doRedirectToHTTPS(redirectToHTTPSConfig *serverconfigs. newURL := "https://" + host + this.RawReq.RequestURI http.Redirect(this.writer, this.RawReq, newURL, statusCode) + + return true }