ยง2023-07-01

Create a new text file named Caddyfile (no extension). The first thing to type in a Caddyfile is your site's addre

This is a simple Caddyfile file

localhost:8080

respond "Hello, world!"

Why,

$ caddy run
2023/07/01 01:32:16.573	INFO	using adjacent Caddyfile
2023/07/01 01:32:16.577	INFO	admin	admin endpoint started	{"address": "localhost:2019", "enforce_origin": false, "origins": ["//localhost:2019", "//[::1]:2019", "//127.0.0.1:2019"]}
2023/07/01 01:32:16.577	INFO	http	enabling automatic HTTP->HTTPS redirects	{"server_name": "srv0"}
2023/07/01 01:32:16.579	INFO	tls.cache.maintenance	started background certificate maintenance	{"cache": "0x4000376850"}
2023/07/01 01:32:16.594	INFO	tls	cleaning storage unit	{"description": "FileStorage:/opt/xfs/home/alexlai/.local/share/caddy"}
2023/07/01 01:32:16.594	INFO	tls	finished cleaning storage units
2023/07/01 01:32:16.644	INFO	pki.ca.local	root certificate is already trusted by system	{"path": "storage:pki/authorities/local/root.crt"}
2023/07/01 01:32:16.644	INFO	http	enabling HTTP/3 listener	{"addr": ":8080"}
2023/07/01 01:32:16.644	INFO	failed to sufficiently increase receive buffer size (was: 208 kiB, wanted: 2048 kiB, got: 416 kiB). See https://github.com/quic-go/quic-go/wiki/UDP-Receive-Buffer-Size for details.
2023/07/01 01:32:16.645	INFO	http.log	server running	{"name": "srv0", "protocols": ["h1", "h2", "h3"]}
2023/07/01 01:32:16.645	INFO	tls.cache.maintenance	stopped background certificate maintenance	{"cache": "0x4000376850"}
Error: loading initial config: loading new config: http app module: start: listening on :80: listen tcp :80: bind: permission denied

Chnge the Caddyfile to


http://localhost:8080 {
        respond "Hello, world!"
}

Then,

$ caddy run
2023/07/01 01:54:44.979 INFO    using adjacent Caddyfile
2023/07/01 01:54:44.986 INFO    admin   admin endpoint started  {"address": "localhost:2019", "enforce_origin": false, "origins": ["//localhost:2019", "//[::1]:2019", "//127.0.0.1:2019"]}
2023/07/01 01:54:44.987 INFO    tls     cleaning storage unit   {"description": "FileStorage:/opt/xfs/home/alexlai/.local/share/caddy"}
2023/07/01 01:54:44.987 INFO    tls     finished cleaning storage units
2023/07/01 01:54:44.987 INFO    http.log        server running  {"name": "srv0", "protocols": ["h1", "h2", "h3"]}
2023/07/01 01:54:44.988 INFO    autosaved config (load with --resume flag)      {"file": "/opt/xfs/home/alexlai/.local/share/caddy/autosave.json"}
2023/07/01 01:54:44.988 INFO    serving initial configuration
2023/07/01 01:54:44.997 INFO    tls.cache.maintenance   started background certificate maintenance      {"cache": "0x400049d3b0"}