I encountered this issue while migrating from Nginx + Varnish to Caddy with Souin. I noticed that the handler label in the metrics from Caddy consistently shows as subroute, like this:
I couldn’t find any answers in the Caddy community or GitHub issues, so I decided to investigate it myself.
1. Switch to Caddy’s native configuration language
Caddy’s native config language is JSON, but writing JSON by hand can be tedious and error-prone. That’s why Caddy supports being configured with other languages through config adapters.
So, the first step is to convert my Caddyfile back to JSON:
Then previously it would become a host matcher at a top-level route in the JSON, which is used for activating automatic HTTPS. (See #5124.) This is unexpected, so now we only avoid wrapping the site block if there is no host matcher. A host matcher defined in that fashion should stay within a subroute because auto-HTTPS is not expected on it.
3. Conclusion
Then I go back and check my caddyfile. I do find there is a host matcher in it. After remove it, there is my handlers came back.