Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS
Mirrored from https://github.com/Slazee/caddy.git
Synced Nov 14, 05:15 UTC
host matcher: Strip [ ] from IPv6 addresses
Matthew Holt committed
Sep 18, 2019 at 09:45 UTC
bc9f9448370d7a5535b33e7407760998b4875e45
2 files changed
+5
-1
caddyconfig/httpcaddyfile/httptype.go
+1
-1
@@ -268,7 +268,7 @@ func (st *ServerType) serversFromPairings(
268
}
269
if _, ok := sblock.pile["tls.off"]; ok {
270
// tls off: disable TLS (and automatic HTTPS) for server block's names
271
- if srv.AutoHTTPS == nil {
271
+ if srv.AutoHTTPS == nil && len(autoHTTPSQualifiedHosts) > 0 {
272
srv.AutoHTTPS = new(caddyhttp.AutoHTTPSConfig)
273
}
274
srv.AutoHTTPS.Skip = append(srv.AutoHTTPS.Skip, autoHTTPSQualifiedHosts...)
modules/caddyhttp/matchers.go
+4
@@ -112,6 +112,10 @@ func (m MatchHost) Match(r *http.Request) bool {
112
if err != nil {
113
// OK; probably didn't have a port
114
reqHost = r.Host
115
+
116
+ // make sure we strip the brackets from IPv6 addresses
117
+ reqHost = strings.TrimPrefix(reqHost, "[")
118
+ reqHost = strings.TrimSuffix(reqHost, "]")
119
}
120
121
outer: