diff --git a/dispatcher.go b/dispatcher.go index 25c949c0..a79d35d3 100644 --- a/dispatcher.go +++ b/dispatcher.go @@ -102,10 +102,8 @@ var localHostIpv4 = regexp.MustCompile(`127\.0\.0\.\d+`) // IsLocalHost checks whether the destination host is explicitly local host // (buggy, there can be IPv6 addresses it doesn't catch) var IsLocalHost ReqConditionFunc = func(req *http.Request, ctx *ProxyCtx) bool { - return req.URL.Host == "::1" || - req.URL.Host == "0:0:0:0:0:0:0:1" || - localHostIpv4.MatchString(req.URL.Host) || - req.URL.Host == "localhost" + h := req.URL.Hostname() + return h == "::1" || h == "0:0:0:0:0:0:0:1" || localHostIpv4.MatchString(h) || h == "localhost" } // UrlMatches returns a ReqCondition testing whether the destination URL