1. The problem I’m having:
I have a local directory with an index.html
file, and I want to serve it locally, so the Caddyfile is very simple. I have a lot of other Caddyfiles, much more complicated, and everything works flawlessly.
My first test was with the caddy CLI : caddy file-server --listen :2019
, executed in the directory, and everything works.
But then I tried this Caddyfile, thinking it was identical with the cli options :
http://localhost:2019 {
log
file_server
}
and it doesn’t work. The logs even in debug mode are not helpful to me :
$ caddy run
2024/11/08 10:44:59.258 INFO using adjacent Caddyfile
2024/11/08 10:44:59.259 INFO adapted config to JSON {"adapter": "caddyfile"}
2024/11/08 10:44:59.259 WARN Caddyfile input is not formatted; run 'caddy fmt --overwrite' to fix inconsistencies {"adapter": "caddyfile", "file": "Caddyfile", "line": 2}
2024/11/08 10:44:59.260 INFO admin admin endpoint started {"address": "localhost:2019", "enforce_origin": false, "origins": ["//localhost:2019", "//[::1]:2019", "//127.0.0.1:2019"]}
2024/11/08 10:44:59.260 DEBUG http.auto_https adjusted config {"tls": {"automation":{"policies":[{}]}}, "http": {"servers":{"srv0":{"listen":[":2019"],"routes":[{"handle":[{"handler":"subroute","routes":[{"handle":[{"browse":{},"handler":"file_server","hide":["./Caddyfile"]}]}]}],"terminal":true}],"automatic_https":{"skip":["localhost"]},"logs":{"logger_names":{"localhost":[""]}}}}}}
2024/11/08 10:44:59.260 INFO tls.cache.maintenance started background certificate maintenance {"cache": "0xc00065f100"}
2024/11/08 10:44:59.260 DEBUG http starting server loop {"address": "[::]:2019", "tls": false, "http3": false}
2024/11/08 10:44:59.260 INFO http.log server running {"name": "srv0", "protocols": ["h1", "h2", "h3"]}
2024/11/08 10:44:59.261 INFO autosaved config (load with --resume flag) {"file": "/home/marrco/.config/caddy/autosave.json"}
2024/11/08 10:44:59.261 INFO serving initial configuration
2024/11/08 10:44:59.266 INFO tls storage cleaning happened too recently; skipping for now {"storage": "FileStorage:/home/marrco/.local/share/caddy", "instance": "f02a28c7-4ce7-475e-8608-eb5358e4c9dd", "try_again": "2024/11/09 10:44:59.266", "try_again_in": 86399.999999449}
2024/11/08 10:44:59.267 INFO tls finished cleaning storage units
2024/11/08 10:45:04.992 INFO admin.api received request {"method": "GET", "host": "127.0.0.1:2019", "uri": "/index.html", "remote_ip": "127.0.0.1", "remote_port": "51224", "headers": {"Accept":["text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"],"Accept-Encoding":["gzip, deflate, br, zstd"],"Accept-Language":["fr,fr-FR;q=0.8,en-US;q=0.5,en;q=0.3"],"Connection":["keep-alive"],"Cookie":["CSRF-Token-4ZEIO=XSH4znbRXSnGTN7LmbXAFYCqTjzUU9Ri; CSRF-Token-V5VIE=pdHLtPVKetNamMnD46LdSAkqq6rX72Zq; CSRF-Token-4ZEIOVS=vi7SMHrbFmCMNtNver59U7wtGeWjXQi93CKdLRgXX25rKuHzXd6aqbPTkkVy9MoP; CSRF-Token-V5VIEAQ=VxuXkqACW7Zfw9JAVGqEu7ApWY6hfZzdP2dxDZHYWKWmdewCY5hx6C33nepu3wRH"],"Priority":["u=0, i"],"Sec-Fetch-Dest":["document"],"Sec-Fetch-Mode":["navigate"],"Sec-Fetch-Site":["none"],"Sec-Fetch-User":["?1"],"Upgrade-Insecure-Requests":["1"],"User-Agent":["Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:132.0) Gecko/20100101 Firefox/132.0"]}}
I don’t want to use https, even locally with self certificate because my port 80 is already in use.
What do I do wrong here ? I guess it’s a simple mistake on my end but I cannot find it.
Thank you
3. Caddy version:
caddy v2.8.4 on ubuntu 24.04