hosting:caddy:setup
Table of Contents
Caddy Setup
Install and configure Caddy as a reverse proxy with automatic HTTPS.
Caddy automatically handles HTTPS certificates and routes traffic to your services.
Overview
Caddy is a modern web server that automatically handles HTTPS certificates using Let's Encrypt. It serves as a reverse proxy, routing traffic to your backend services while managing TLS certificates automatically.
Benefits of Caddy
- Automatic HTTPS with Let's Encrypt
- Simple configuration with Caddyfile
- Automatic certificate renewal
- HTTP to HTTPS redirects
- Modern security defaults
Docker Setup
Create a `docker-compose.yml` with Caddy: ```yaml services:
caddy:
image: caddy:2-alpine
container_name: caddy
restart: unless-stopped
ports:
- "80:80"
- "443:443"
volumes:
- ./Caddyfile:/etc/caddy/Caddyfile:ro
- caddy_data:/data
- caddy_config:/config
volumes:
caddy_data: caddy_config:
```
The `caddy_data` volume stores TLS certificates so they persist across container restarts.
Create Caddyfile
Create a `Caddyfile` in the same directory: ``` your-domain.com {
reverse_proxy whoami:80
} ```
Caddy will automatically:
- Obtain a Let's Encrypt certificate
- Enable HTTPS
- Redirect HTTP to HTTPS
- Renew certificates automatically
Start Caddy
```bash docker compose up -d ```
Test HTTPS
```bash curl -I https://your-domain.com ```
You should see HTTPS response headers.
References
See Also
hosting/caddy/setup.txt · Last modified: by 127.0.0.1
