Browse Source

httpcaddyfile: Fix ordering of catch-all site blocks

Catch-alls should always go last. Normally this is the case, but we have
a special case for comparing one wildcard-host site block to another
non-wildcard host site block; and a catch-all site block is also a
non-wildcard host site block, so now we have to special-case the
catch-all site block. Sigh.

This could be reproduced with a Caddyfile that has two site blocks:
":80" and "*.example.com", in that order.
master
Matthew Holt 5 years ago
parent
commit
32cafbb630
No known key found for this signature in database GPG Key ID: 2A349DD577D586A5
  1. 5
      caddyconfig/httpcaddyfile/httptype.go

5
caddyconfig/httpcaddyfile/httptype.go

@ -400,6 +400,11 @@ func (st *ServerType) serversFromPairings(
jLongestPath = addr.Path
}
}
if specificity(jLongestHost) == 0 {
// catch-all blocks (blocks with no hostname) should always go
// last, even after blocks with wildcard hosts
return true
}
if iWildcardHost != jWildcardHost {
// site blocks that have a key with a wildcard in the hostname
// must always be less specific than blocks without one; see

Loading…
Cancel
Save