summaryrefslogtreecommitdiff
path: root/caddyconfig
diff options
context:
space:
mode:
authorMatthew Holt <mholt@users.noreply.github.com>2020-06-16 10:02:06 -0600
committerMatthew Holt <mholt@users.noreply.github.com>2020-06-16 10:02:06 -0600
commit32cafbb6309c8d78cc7e2f2a75def9c633944ef8 (patch)
tree7cb6a34c393f51ab49bfae504c8f7b42e6dd742f /caddyconfig
parent003403ecbccbd3fa53040ee1f0fd5d411a887215 (diff)
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.
Diffstat (limited to 'caddyconfig')
-rw-r--r--caddyconfig/httpcaddyfile/httptype.go5
1 files changed, 5 insertions, 0 deletions
diff --git a/caddyconfig/httpcaddyfile/httptype.go b/caddyconfig/httpcaddyfile/httptype.go
index 7be932f..3f37f02 100644
--- a/caddyconfig/httpcaddyfile/httptype.go
+++ b/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