💾 Archived View for zvava.org › wiki › caddy.gmi captured on 2024-08-31 at 11:57:47. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2024-08-24)

🚧 View Differences

-=-=-=-=-=-=-

🏡 go home...

🗃️ go back...

caddy

thumbnail (caddy.png)

created  2024/06/09
category info, internet
views    93

caddy is a web server that is extremely powerful yet simple to configure

website

documentation

configuration

by default, for every domain block in the configuration file, caddy automatically acquires a let's encrypt certificate for them!! but does not provide a regular http endpoint. if you want regular http (port 80) too you will have to manually specify that

example.com, http://example.com {
	file_server {
		root /var/www/
		hide .*
		browse /etc/caddy/browse.tmpl
	}

	handle_errors {
		@404 expression {err.status_code} == 404
		rewrite @404 /404.html
	}
}

when a user vists example.com, on either https or http: we serve static files from `/var/www`, using the template `/etc/caddy/browse.tmpl` for directories without an index.html file, but not showing hidden files; we also redirect to a `/404.html` file on a 404 error

AND we don't have to get our hands dirty setting up certificates by hand or with acme.sh or anything to have it encrypted

yes, that's really the whole configuration file for that‼️

reverse proxy

using the `reverse_proxy` directive, you can add tls/ssl to any regular service that doesn't support https://, or even just have it automatically be set up for ones that do! i also use this to expose services hosted on other machines that are forwarded to my server with frp

git.zvava.org {
	reverse_proxy localhost:8080
}

frp (fast reverse proxy)

snippets

to use a snippet use the `import` directive, eg. `import respond_file ...`

respond to a request with a specific file (second argument) from a specific directory (first argument):

(respond_file) {
	root * {args[0]}
	try_files {args[1:]}
	file_server
}