1. The problem I’m having:
I want to have different behavior when a default match happens in the map directive, and I can’t seem to get it to work.
For any other sub-subdomain except for the listed ones, I should get a 404 response, but I’m currently getting a 502, and from the logs it looks like caddy is still trying to reverse proxy for those cases. I don’t quite understand why it’s happening.
2. Error messages and/or full log output:
"logger":"http.log.error","msg":"dial tcp: lookup dummy on 8.8.8.8:53: no such host"
when trying to access an “invalid” route.
3. Caddy version:
v2.8.4 h1:q3pe0wpBj1OcHFZ3n/1nl4V4bxBrYoSoab7rL9BMYNk=
4. How I installed and ran Caddy:
a. System environment:
AlmaLinux 9.4 x86_64b. Command:
systemctl enable --now caddy
c. Service/unit/compose file:
Irrelevant.
d. My complete Caddy config:
vps6.dedyn.io, *.vps6.dedyn.io {
tls {
dns desec {
token "<token>"
}
}
map {labels.3} {backend} {prt} {
files localhost 5091
jellyfin server 80
music server 80
default dummy 0
}
@invalid `{prt} == 0`
handle @invalid {
respond 404
}
reverse_proxy {backend}:{prt}
}
5. Links to relevant resources:
I was trying to use this solution.