

Yeah I can understand small self-hosters having maybe a handful of domains but some users were coming in with thousands. I mean if you have thousands of domains there’s obviously something else going on and maybe you should be paying someone for that.


In my case I have defined a fallback in Caddy so any request that doesn’t match one of the explicitly handled domains will be an error.
I use a
route {}block withhandle {}blocks inside it, and the last handle has anerrordirective in it.https://*.example.com { route { @foo host "foo.example.com" handle @foo { reverse_proxy http://whatever:12334/ } ... more proxy hosts ... handle { error 400 } } }The
routeblock is essential here because handlers inside a route block are processed strictly in the order they are defined. Outside route blocks that is not true, caddy will try to optimize and can execute directives in any order it sees fit.