3 ms·
caddy file-server does this, but more production-ready, honors cache headers, sets Etag, etc. Also: caddy respond can be used to hard-code specific resp
by mholt 3y ago
caddy file-server
does this, but more production-ready, honors cache headers, sets Etag, etc.
Also:
caddy respond
can be used to hard-code specific responses if you're testing an HTTP client. It can even spin up on a whole port range and supports templates in the response text right there on the command line:
caddy respond --listen :2000-2004 "I'm server {{.N}} on port {{.Port}}"
Here's an example maintenance page:
cat maintenance.html | caddy respond \
--listen :80 \
--status 503 \
--header "Content-Type: text/html"
https://caddyserver.com/docs/command-line https://caddyserver.com/docs/command-line
- Alifatisk 3y agoIs caddy that easy to setup and run?
- yjftsjthsd-h 3y agoI'd say "easy to setup and run" is arguably caddy's entire point:) Single binary file, yes running is that easy for simple stuff, and honestly it's not exactly complicated for more complex stuff. It got a lot of its popularity because it made HTTPS, including automatic cert provisioning, utterly trivial.
- iainmerrick 3y agoIt’s pretty easy, but I find the config file format rather confusing. In the classic Unix style, you’re learning yet another little language, so there’s a learning curve. Once you learn it, it’s fairly powerful and expressive, but the docs aren’t very clear.
- e12e 3y agoYes. Caddy excels at making simple [1] use-cases trivial - either with no config, or 3-5 lines of config. It might seem jarring comming from Apache or nginx - but i think a lot of it comes from the developers having destilled a lot of common use-cases and carefully chosen reasonable defaults. [1] Simple to articulate; not necessarily simple to execute - eg letsencrypt works out of the box. Caddy will give you https if you ask (or rather unless you go out of your way to avoid it). It can be a great stop-gap in running an ssl proxy in front of a legacy application server stuck on some horrible old distro, for example - since the binary just needs a Linux kernel (and can ignore old ssl libraries).
- eddieroger 3y agoNGINX felt jarring coming from Apache. The cycle continues. To be fair to NGINX, there is a lot of boilerplate config, but if you have a good set of default files, the server blocks can be small. The same could be said for Apache, of course. But yeah, Caddy is great in how little config it takes, no boilerplate, to do what the incumbents do.
- yjftsjthsd-h 3y agoIt would be polite to note that you wrote caddy. (It's a good tool and appropriate here, but disclaimers for self-promotion are always in style)