Gem devopshttps

Caddy

A web server and reverse proxy with automatic HTTPS.

Would you recommend Caddy?

No votes yet. Tried it? Be the first to say.

One vote per person. No account needed.

Overview

Caddy obtains and renews TLS certificates on its own, and its config is a few readable lines. It also issues trusted local certificates for development domains.

Instead of

nginx + certbot + cron renewal jobs

Reach for it when

You need a reverse proxy or static file server and don't want to manage certificates.

Key features

  • Automatic HTTPS

    Obtains and renews certificates from Let's Encrypt or ZeroSSL by itself, and redirects HTTP to HTTPS.

  • Simple config

    A Caddyfile site is often two or three lines; a full JSON config and admin API are available for automation.

  • Reverse proxy

    Load balancing, health checks, retries, header manipulation and WebSocket support built in.

  • Static file server

    Compression, ranges, directory browsing and SPA fallbacks with try_files.

  • Modern protocols

    HTTP/2 and HTTP/3 out of the box.

  • Local HTTPS

    An internal CA issues trusted certificates for localhost and internal hostnames.

In depth

Caddyfile examples

text
# A reverse proxy with automatic HTTPS
app.example.com {
    reverse_proxy localhost:3000
}

# A static single-page app with an API behind it
example.com {
    root * /srv/site
    encode zstd gzip
    handle /api/* {
        reverse_proxy localhost:8080
    }
    handle {
        try_files {path} /index.html
        file_server
    }
}

# Load balance across two app instances with health checks
api.example.com {
    reverse_proxy 10.0.0.11:8080 10.0.0.12:8080 {
        lb_policy least_conn
        health_uri /health
    }
}
bash
caddy run --config Caddyfile     # foreground
caddy reload --config Caddyfile  # zero-downtime config reload

How automatic HTTPS works

When a site block names a public domain, Caddy completes an ACME challenge with a certificate authority, stores the certificate, staples OCSP responses and renews well before expiry, all in the background. For localhost or internal names, it uses its own local CA instead (run caddy trust to install that CA on your machine).

Good to know

  • Point DNS at the server and open ports 80 and 443 before starting it, or certificate issuance will fail.
  • Coolify and similar platforms often run Caddy or Traefik for you; you may already be using it.

Strengths

  • Removes a whole class of outages: expired certificates and forgotten renewal cron jobs.
  • Configs are short and readable, so they're easy to review and hard to get wrong.
  • Secure defaults (modern TLS, HSTS-friendly) without copy-pasting hardening snippets.
  • A single static binary with no dependencies.

Watch out for

  • Extra modules (DNS providers, rate limiting and so on) require a custom build with xcaddy.
  • There are far fewer Stack Overflow answers and copy-paste snippets than for nginx.
  • At very high scale, nginx and HAProxy have more tuning history and production lore.

Try it in a few minutes

Terminal
brew install caddy   # or see the install docs
caddy reverse-proxy --from localhost:8443 --to localhost:3000

Alternatives

nginx + certbot

The ubiquitous standard; very fast and flexible, but certificate management is a separate job.

Traefik

Automatic HTTPS plus service discovery from Docker labels and Kubernetes, popular in container setups.

HAProxy

A high-performance load balancer, more focused on TCP/HTTP proxying than serving files.

Related tools

Other tools that share topics with Caddy.

Molecule

ansible.readthedocs.io
Gem

Test your Ansible roles and collections in throwaway containers or VMs.

Instead of Running playbooks against a shared dev box and hoping

Litestream

litestream.io
Gem

Continuously stream SQLite changes to S3-compatible storage.

Instead of Nightly cron backups of a .sqlite file, or moving to Postgres just for durability

mise

mise.jdx.dev
Gem

One tool to pin Node, Python, Go and more per project, plus env vars and tasks.

Instead of nvm + pyenv + asdf + direnv + ad-hoc scripts