What is Caddy?
Caddy is a modern web server written in Go that automatically handles HTTPS via Let's Encrypt. It requires minimal configuration and is perfect for simple deployments.
Installation
sudo apt install -y debian-keyring debian-archive-keyring apt-transport-https
curl -1sLf "https://dl.cloudsmith.io/public/caddy/stable/gpg.key" | sudo gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg
curl -1sLf "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 caddyCaddyfile Configuration
Edit /etc/caddy/Caddyfile:
# Static site (auto HTTPS!)
example.com {
root * /var/www/html
file_server
}
# Reverse proxy
api.example.com {
reverse_proxy localhost:3000
}
# PHP site
mysite.com {
root * /var/www/mysite
php_fastcgi unix//run/php/php8.2-fpm.sock
file_server
}Key Features
- Automatic HTTPS — obtains and renews certificates with zero configuration
- Single binary — no dependencies needed
- HTTP/2 and HTTP/3 — enabled by default
- Simple config — the Caddyfile is far more readable than Nginx/Apache configs
Reload After Changes
sudo systemctl reload caddy