🔒
blog.cat.ssl

Caddy server: how automatic HTTPS works and how to set it up on a VPS

26.11.2026
← All articles

For most VPS owners the tedious part of SSL is not installing a certificate but making sure it renews every few months. With Nginx or Apache you install Certbot separately, set up a cron job or systemd timer and remember to reload the server afterwards. Caddy takes a different approach: certificate issuance and renewal are built into the web server itself. You write the domain name in the config and Caddy handles the rest.

How Caddy does automatic HTTPS

On startup Caddy reads every hostname in its configuration and requests a certificate for it over ACME. By default it uses Let's Encrypt and can fall back to another free certificate authority if needed. Domain control is proven with the HTTP-01 or TLS-ALPN-01 challenge, so the server must be reachable from the internet on ports 80 and 443. Once a certificate is issued, Caddy redirects HTTP to HTTPS automatically and renews it in the background well before it expires. Certificates are stored on disk, usually under /var/lib/caddy/.local/share/caddy for the systemd service, so a reboot does not trigger new requests.

Installing on Ubuntu or Debian

The official Caddy docs provide a package repository for Debian and Ubuntu. These commands add it and install Caddy as a systemd service. If Nginx or Apache is already listening on ports 80 and 443, stop it first, because two web servers cannot share the same port.

sudo apt install -y debian-keyring debian-archive-keyring apt-transport-https curl
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 caddy

A Caddyfile for a static site

The main config lives at /etc/caddy/Caddyfile. Imagine a small building-supplies shop in Tashkent whose catalogue is plain HTML in /var/www/example. This config gets certificates for both names, serves the files and compresses responses. The global block at the top sets a contact email for the certificate authority; no separate keyword is needed to turn SSL on.

{
    email admin@example.uz
}

example.uz, www.example.uz {
    root * /var/www/example
    file_server
    encode gzip
}

Reverse proxy and redirects

Caddy is often placed in front of a Node.js or Python application. A private clinic running an appointment app on port 3000 does not need to expose that port; Caddy terminates HTTPS and forwards requests to the app over plain HTTP, passing the client IP in X-Forwarded-For. Bind the app to 127.0.0.1 so nobody can bypass Caddy.

api.example.uz {
    reverse_proxy 127.0.0.1:3000
}

misol.uz {
    redir https://www.misol.uz{uri} permanent
}

www.misol.uz {
    reverse_proxy 127.0.0.1:8080
}

Validate and reload

After editing the Caddyfile you do not need a full restart. Format and validate the file, then reload gracefully without dropping connections. Everything related to certificate issuance goes to the journal, so read it first when something goes wrong.

caddy fmt --overwrite /etc/caddy/Caddyfile
caddy validate --config /etc/caddy/Caddyfile
sudo systemctl reload caddy
sudo journalctl -u caddy --no-pager -n 50

When the certificate is not issued

The most common cause is DNS: the domain's A record must point to this VPS's public IP, and a freshly added record may need some time to propagate. The second is a firewall blocking port 80 or 443. The third is restarting Caddy over and over with a broken setup, which can hit the CA's rate limits; while testing, point the acme_ca global option at the Let's Encrypt staging server. If the domain sits behind a proxy such as Cloudflare, the challenge may not reach your server, so either pause the proxy or use DNS-01 with the matching Caddy DNS module.

dig +short example.uz A
sudo ss -tlnp | grep -E ':80|:443'
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp

When Caddy is the right choice

Caddy needs a server you control, such as a VPS. On shared hosting the panel provides SSL instead; on sayt.uz hosting, for example, a free auto-renewing Let's Encrypt certificate is enabled right in the panel. If your team already knows Nginx well or has complex rules in place, staying with Nginx and Certbot is perfectly fine. Caddy shines when you want minimal configuration and no risk of forgetting a renewal.

Related articles

📈 HTTPS and SEO: What the Real Impact Looks Like in 2026 ⛔ Revoking an SSL certificate: when you need it and how to do it 🔐 ZeroSSL, Buypass and Other Free SSL Authorities Beyond Let's Encrypt 🌐 Can you get an SSL certificate for an IP address, and when does it make sense?
🌐 Language
🇺🇿 O⁠'zbek 🇺🇿 Özbek (yangi) 🇺🇿 Ўзбек 🇷🇺 Русский 🇬🇧 English ✓