This repository provides a simple and production-friendly setup for Caddy as a reverse proxy. It’s designed to be minimal yet flexible — ideal for hosting your personal website, portfolio projects, or Docker-based web services.
At first, I considered using Nginx or Traefik. However, both felt like overkill for small self-hosted projects and required more configuration effort.
Caddy, on the other hand, offers:
- Simple and declarative configuration
- Automatic HTTPS with Let’s Encrypt
- Excellent Docker integration
- Lightweight and easy to maintain, you can easily switch to another reverse proxy later if needed
That’s why I chose Caddy as my go-to reverse proxy for this use case.
- A domain
- A VPS or local machine running Linux (tested on Ubuntu & Arch Linux)
- Docker and Docker Compose installed
- A Docker network named
application_network
-
Clone this repository:
git clone https://github.com/wolewd/caddy.git cd caddy -
Run the Caddy container:
docker compose up -d
-
Access your site:
https://your-domain.com
By default, this setup is designed to work with Cloudflare Tunnel, so there’s no need to expose ports 80 or 443 publicly — Cloudflare handles secure routing.
Modify your Caddyfile if you running your services in other container:
{
auto_https off
}
www.example.com:80 {
redir http://example.com{uri} permanent
}
example.com:80 {
reverse_proxy container-name:8080
}Change example.com to your domain andd make sure you change container-name:8080 to your service container and port.
You can also remove www.example.com block if you don't use www sub domain.
Cloudflare tunnel will handle the TLS for you.
If you want to expose your Caddy instance directly to the internet, you’ll need to make a few small adjustments:
-
Update your
docker-compose.yamlto map Caddy’s HTTP and HTTPS ports to your host machine. Replace this section:expose: - "80" - "443"
With:
ports: - "80:80" - "443:443"
-
Update your
Caddyfileto directly serve your domain by replacing your existing configuration with this:example.com { root * /srv file_server encode gzip }
Change
example.comto your domain — Caddy will automatically handle SSL certificates for you. Don't forget to map your domain DNS directly to your server IP.