Browse Source

host matcher: Strip [ ] from IPv6 addresses

master
Matthew Holt 6 years ago
parent
commit
bc9f944837
No known key found for this signature in database GPG Key ID: 2A349DD577D586A5
  1. 2
      caddyconfig/httpcaddyfile/httptype.go
  2. 4
      modules/caddyhttp/matchers.go

2
caddyconfig/httpcaddyfile/httptype.go

@ -268,7 +268,7 @@ func (st *ServerType) serversFromPairings(
}
if _, ok := sblock.pile["tls.off"]; ok {
// tls off: disable TLS (and automatic HTTPS) for server block's names
if srv.AutoHTTPS == nil {
if srv.AutoHTTPS == nil && len(autoHTTPSQualifiedHosts) > 0 {
srv.AutoHTTPS = new(caddyhttp.AutoHTTPSConfig)
}
srv.AutoHTTPS.Skip = append(srv.AutoHTTPS.Skip, autoHTTPSQualifiedHosts...)

4
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:

Loading…
Cancel
Save