1. The problem I’m having:
I have a Caddyfile and it is not behaving as I would expect. Clearly I am doing something stupid, but the simple logging I get from Caddy isn’t making it obious to me.
I’ve added this to my logging:
log {
output stderr
level DEBUG
format console
}
But I really want debug logging on all the steps / routing that Caddy does when it gets a request.
Is there a way to do that?
I think I’m looking for something like a caddy trace.
2. Error messages and/or full log output:
Here is an example of a “route” that isn’t behaving as I would expect. I want a 404, but am gettign a status 0.
❯ sudo caddy run --watch
2024/01/18 17:51:40.018 INFO using adjacent Caddyfile
2024/01/18 17:51:40.021 INFO admin admin endpoint started {"address": ":2020", "enforce_origin": false, "origins": ["//:2020"]}
2024/01/18 17:51:40.022 WARN admin admin endpoint on open interface; host checking disabled {"address": ":2020"}
2024/01/18 17:51:40.022 INFO tls.cache.maintenance started background certificate maintenance {"cache": "0x40001dca00"}
2024/01/18 17:51:40.023 INFO http.log server running {"name": "srv0", "protocols": ["h1", "h2", "h3"]}
2024/01/18 17:51:40.023 INFO autosaved config (load with --resume flag) {"file": "/root/.config/caddy/autosave.json"}
2024/01/18 17:51:40.024 INFO serving initial configuration
2024/01/18 17:51:40.025 INFO watcher watching config file for changes {"config_file": "Caddyfile"}
2024/01/18 17:51:40.030 WARN tls storage cleaning happened too recently; skipping for now {"storage": "FileStorage:/root/.local/share/caddy", "instance": "a17a05a9-f18d-473b-b66f-5a5130b00643", "try_again": "2024/01/19 17:51:40.030", "try_again_in": 86399.999999444}
2024/01/18 17:51:40.030 INFO tls finished cleaning storage units
2024/01/18 17:51:49.407 INFO http.log.access.log0 handled request {"request": {"remote_ip": "127.0.0.1", "remote_port": "60358", "client_ip": "127.0.0.1", "proto": "HTTP/1.1", "method": "GET", "host": "localhost:81", "uri": "/bogus", "headers": {"User-Agent": ["curl/7.88.1"], "Accept": ["*/*"]}}, "bytes_read": 0, "user_id": "", "duration": 0.000006704, "size": 0, "status": 0, "resp_headers": {"Server": ["Caddy"]}}
3. Caddy version:
v2.7.6 h1:w0NymbG2m9PcvKWsrXO6EEkY9Ru4FJK8uQbYcev1p3A=
4. How I installed and ran Caddy:
a. System environment:
Raspbian: Linux pi5-seattle 6.1.0-rpi7-rpi-2712 #1 SMP PREEMPT Debian 1:6.1.63-1+rpt1 (2023-11-24) aarch64 GNU/Linux
b. Command:
sudo apt install caddy
c. Service/unit/compose file:
d. My complete Caddy config:
{
admin :2020 # 2019 is in use
}
:81 {
log {
output stderr
level DEBUG
format console
}
handle /ha {
redir http://pi-seattle:8123/dashboards-all/Overview 302
}
handle_errors {
rewrite * /404.html
templates
file_server
}
}