DEV Community

Alex Spinov
Alex Spinov

Posted on

Caddy Has a Free API — The Automatic HTTPS Web Server

Caddy is a web server that automatically provisions HTTPS certificates. No configuration files needed — it just works.

What Is Caddy?

Caddy is the only web server that provisions and renews TLS certificates automatically via Let us Encrypt. Written in Go, single binary, zero dependencies.

Features:

  • Automatic HTTPS (Let us Encrypt + ZeroSSL)
  • HTTP/3 support
  • Reverse proxy
  • Load balancing
  • API-first configuration
  • Single binary

Quick Start

# Install
curl -fsSL https://getcaddy.com | bash

# Serve current directory with HTTPS
caddy file-server --domain yourdomain.com

# Reverse proxy
caddy reverse-proxy --from yourdomain.com --to localhost:3000
Enter fullscreen mode Exit fullscreen mode

Admin API

# Get current config
curl localhost:2019/config/

# Set config
curl -X POST localhost:2019/config/ \
  -H "Content-Type: application/json" \
  -d '{"apps":{"http":{"servers":{"main":{"listen":[":443"],"routes":[{"match":[{"host":["example.com"]}],"handle":[{"handler":"reverse_proxy","upstreams":[{"dial":"localhost:3000"}]}]}]}}}}}'

# Add route dynamically
curl -X POST localhost:2019/config/apps/http/servers/main/routes \
  -d '{"match":[{"host":["api.example.com"]}],"handle":[{"handler":"reverse_proxy","upstreams":[{"dial":"localhost:8080"}]}]}'
Enter fullscreen mode Exit fullscreen mode

Caddyfile (simpler config)

example.com {
  reverse_proxy localhost:3000
}

api.example.com {
  reverse_proxy localhost:8080
}
Enter fullscreen mode Exit fullscreen mode

Use Cases

  1. HTTPS proxy — automatic SSL for any backend
  2. Static hosting — serve files with HTTPS
  3. Load balancer — distribute traffic
  4. API gateway — route and secure APIs
  5. Development — local HTTPS for testing

Need web data at scale? Check out my scraping tools on Apify or email spinov001@gmail.com for custom solutions.

Top comments (0)