DEV Community

Alex Spinov
Alex Spinov

Posted on

Caddy Has a Free API: The Web Server with Automatic HTTPS

Why Caddy

Caddy is a web server that gets HTTPS automatically — Let's Encrypt certificates provisioned and renewed without any configuration. Zero-downtime reloads, HTTP/3, reverse proxy — all built-in.

Install

brew install caddy
# or
curl -fsSL https://github.com/caddyserver/caddy/releases/latest/download/caddy_linux_amd64 -o /usr/local/bin/caddy
Enter fullscreen mode Exit fullscreen mode

Serve a Static Site (Automatic HTTPS)

# Caddyfile
mysite.com {
    root * /var/www/mysite
    file_server
}
Enter fullscreen mode Exit fullscreen mode

That is it. Caddy automatically gets a TLS certificate from Let's Encrypt.

Reverse Proxy

api.mysite.com {
    reverse_proxy localhost:8080
}

app.mysite.com {
    reverse_proxy localhost:3000
}
Enter fullscreen mode Exit fullscreen mode

Load Balancing

api.mysite.com {
    reverse_proxy {
        to localhost:8001 localhost:8002 localhost:8003
        lb_policy round_robin
        health_uri /health
        health_interval 10s
    }
}
Enter fullscreen mode Exit fullscreen mode

Caddy Admin API

# Get current config
curl http://localhost:2019/config/

# Update config without restart
curl -X PATCH http://localhost:2019/config/apps/http/servers/srv0/routes \
  -H 'Content-Type: application/json' \
  -d '[{"handle": [{"handler": "static_response", "body": "Hello!"}]}]'

# Reload from Caddyfile
caddy reload
Enter fullscreen mode Exit fullscreen mode

Key Features

  • Automatic HTTPS — Let's Encrypt, ZeroSSL, built-in
  • HTTP/3 — enabled by default
  • Admin API — dynamic config without restart
  • Reverse proxy — with health checks, load balancing
  • Compression — gzip, zstd built-in
  • Single binary — no dependencies

Caddy vs Nginx

Feature Caddy Nginx
Auto HTTPS Built-in Certbot required
Config Caddyfile (simple) nginx.conf (complex)
HTTP/3 Default Module required
Live reload API-based Signal-based
Config format JSON or Caddyfile Custom

Resources


Need to extract web server configs, SSL data, or traffic metrics? Check out my Apify tools or email spinov001@gmail.com for custom solutions.

Top comments (0)