Caddy
Install
# Official apt repo & package
sudo apt install -y debian-keyring debian-archive-keyring apt-transport-https
curl -fsSL https://dl.cloudsmith.io/public/caddy/stable/gpg.key | sudo tee /usr/share/keyrings/caddy-stable-archive-keyring.gpg >/dev/null
curl -fsSL https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt | sudo tee /etc/apt/sources.list.d/caddy-stable.list
sudo apt update
sudo apt install -y caddy
sudo systemctl enable --now caddy
The official package installs a systemd unit; enabling it makes Caddy persistent.
Basic reverse proxy + automatic HTTPS
Edit /etc/caddy/Caddyfile
:
example.com {
reverse_proxy 127.0.0.1:3000
}
Apply:
sudo caddy validate --config /etc/caddy/Caddyfile
sudo systemctl reload caddy
Caddy automatically obtains/renews certificates from Let’s Encrypt and redirects HTTP→HTTPS by default when using a domain block like above. Reverse proxy behavior is via the reverse_proxy
directive.
Verify
curl -I http://example.com
curl -I https://example.com
journalctl -u caddy -n 100 --no-pager