From bc9f9448370d7a5535b33e7407760998b4875e45 Mon Sep 17 00:00:00 2001 From: Matthew Holt Date: Wed, 18 Sep 2019 09:45:21 -0600 Subject: host matcher: Strip [ ] from IPv6 addresses --- modules/caddyhttp/matchers.go | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'modules/caddyhttp/matchers.go') diff --git a/modules/caddyhttp/matchers.go b/modules/caddyhttp/matchers.go index 9cf52dc..3eaf48f 100644 --- a/modules/caddyhttp/matchers.go +++ b/modules/caddyhttp/matchers.go @@ -112,6 +112,10 @@ func (m MatchHost) Match(r *http.Request) bool { if err != nil { // OK; probably didn't have a port reqHost = r.Host + + // make sure we strip the brackets from IPv6 addresses + reqHost = strings.TrimPrefix(reqHost, "[") + reqHost = strings.TrimSuffix(reqHost, "]") } outer: -- cgit v1.2.3