Caddy: a site with a certificate out of the box
A web server that obtains and renews HTTPS certificates itself. Installation on a VPS, a minimal Caddyfile, and migrating from Nginx.
Updated August 23, 2026
Caddy does the same as Nginx, but issues and renews Let's Encrypt certificates on its own. A site configuration fits in three lines, so for a first project on a VDS it's the shortest path to working HTTPS.
Installation
Debian and Ubuntu — from the official repository:
apt install -y debian-keyring debian-archive-keyring apt-transport-https curl
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' \
| gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' \
> /etc/apt/sources.list.d/caddy-stable.list
apt update && apt install -y caddy
AlmaLinux and CentOS Stream:
dnf install -y 'dnf-command(copr)'
dnf copr enable -y @caddy/caddy
dnf install -y caddy && systemctl enable --now caddy
Your first site
The entire config lives in /etc/caddy/Caddyfile:
example.ru {
root * /var/www/example.ru
file_server
encode gzip zstd
}
mkdir -p /var/www/example.ru
echo '<h1>Works</h1>' > /var/www/example.ru/index.html
caddy validate --config /etc/caddy/Caddyfile
systemctl reload caddy
A few seconds after the first request, the site opens at https://example.ru. You don't need to start anything else: Caddy fetched the certificate itself and will renew it automatically.
Proxying an application
If you have a Node.js or Python service on a local port, the config looks like this:
api.example.ru {
reverse_proxy 127.0.0.1:3000
}
Caddy adds the X-Forwarded-For and X-Forwarded-Proto headers itself. For more on the scheme, see reverse proxy.
Multiple sites are just multiple blocks in the same file, see multiple sites on one machine.
What to check in advance
- The domain's A record points to the machine address from the “Overview” of the panel
/hosting/vds/m/<id>; - ports 80 and 443 are open in the machine's firewall and not taken by Nginx or Apache;
- the domain actually resolves:
dig +short example.ru.
If the first item isn't done, certificate issuance will fail: Let's Encrypt must reach your machine by the domain name.
Common errors
| Symptom | Cause |
|---|---|
could not get certificate | The domain doesn't point to the machine, or port 80 is closed |
address already in use | Nginx or Apache is running — stop one of them |
| The site opens only over HTTP | The Caddyfile specifies :80 or http:// before the name |
| Too many issuance attempts | Let's Encrypt limits — debug with tls internal |
Logs: journalctl -u caddy -f.
Caddy stores certificates in
/var/lib/caddy/.local/share/caddy. When you reinstall the system on the “Access” tab, copy this directory, otherwise issuance will start from scratch after the reinstall.