From 55e49ff5c88170b8978cb322dfea3688fb6d3b97 Mon Sep 17 00:00:00 2001 From: Matthew Holt Date: Mon, 1 Feb 2021 11:45:28 -0700 Subject: httpcaddyfile: Sort catch-all site blocks properly (fix #4003) --- caddyconfig/httpcaddyfile/httptype.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'caddyconfig') diff --git a/caddyconfig/httpcaddyfile/httptype.go b/caddyconfig/httpcaddyfile/httptype.go index c6225df..2e7dd7c 100644 --- a/caddyconfig/httpcaddyfile/httptype.go +++ b/caddyconfig/httpcaddyfile/httptype.go @@ -430,9 +430,12 @@ func (st *ServerType) serversFromPairings( jLongestPath = addr.Path } } + // catch-all blocks (blocks with no hostname) should always go + // last, even after blocks with wildcard hosts + if specificity(iLongestHost) == 0 { + return false + } 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 { -- cgit v1.2.3