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
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.
Matthew Holt committed
Jun 16, 2020 at 10:02 UTC
32cafbb6309c8d78cc7e2f2a75def9c633944ef8
1 file changed
+5
caddyconfig/httpcaddyfile/httptype.go
+5
@@ -400,6 +400,11 @@ func (st *ServerType) serversFromPairings(
400
jLongestPath = addr.Path
401
}
402
}
403
+ if specificity(jLongestHost) == 0 {
404
+ // catch-all blocks (blocks with no hostname) should always go
405
+ // last, even after blocks with wildcard hosts
406
+ return true
407
+ }
408
if iWildcardHost != jWildcardHost {
409
// site blocks that have a key with a wildcard in the hostname
410
// must always be less specific than blocks without one; see