To put a few services behind HTTPS on a Docker VPS, Caddy does it in three lines per domain and never touches the Docker socket. Traefik pays off when containers come and go often: it reads the labels on each one and adds the route by itself, with no reload. This comparison puts the same service behind Caddy 2.11.9 and Traefik v3.8.0 and shows what changes in configuration, HTTPS, security and resource use. Everything was tested on 1 December 2026 on a clean Ubuntu 24.04.5 LTS with Docker Engine 29.10.1 and Compose v5.8.1.
On this page

Quick comparison
| Criterion | Caddy 2.11.9 | Traefik v3.8.0 |
|---|---|---|
| Where the route is | In the Caddyfile, one block per domain |
In labels on each service's container |
| New service | Edit the Caddyfile and run caddy reload |
docker compose up -d; the route appears by itself |
| Docker socket | Not used | Needed to read the labels |
| Automatic HTTPS | On by default | Needs a certresolver with an email and acme.json |
| HTTP to HTTPS | Automatic (308 in the test) | Two flags (301 on GET, 308 on other methods) |
| HTTP/3 | On by default | One more flag and port 443/udp |
| Dashboard | None; admin API on localhost:2019 |
Web dashboard, off by default |
| Memory at rest | About 14 MiB | About 23 MiB |
| Image (amd64) | 93.5 MB | 295 MB |
Memory is each proxy at rest with two services behind it, and should be read as an order of magnitude. Neither one affects which plan you pick: the size of the VPS depends on your applications.
What you need
- A VPS with Ubuntu 24.04, Docker Engine and the Compose plugin, installed as in How to install Docker and Docker Compose on Ubuntu 24.04. The examples use the
deployuser, a member of thedockergroup. - Two DNS
Arecords pointing to the VPS IP. The examples useapp.example.comandapi.example.com. - Ports 80 and 443 free, plus 443/udp for HTTP/3. A port published by Docker bypasses
ufw: see The Docker port stays open with ufw.
The example service is traefik/whoami v1.12.0, which returns the headers of the request it received. Run one proxy at a time: both want ports 80 and 443.
The same service behind Caddy
mkdir -p ~/caddy/conf && cd ~/caddyAPP_DOMAIN=app.example.com{$APP_DOMAIN} {
reverse_proxy whoami:80
}services:
caddy:
image: caddy:2.11.9
restart: unless-stopped
env_file: .env
ports:
- "80:80"
- "443:443"
- "443:443/udp"
volumes:
- ./conf:/etc/caddy:ro
- caddy_data:/data
- caddy_config:/config
whoami:
image: traefik/whoami:v1.12.0
restart: unless-stopped
volumes:
caddy_data:
caddy_config:Validate, start and test:
docker compose config -q
docker run --rm --env-file .env -v "$PWD/conf:/etc/caddy:ro" caddy:2.11.9 caddy validate --config /etc/caddy/Caddyfile
docker compose up -d
curl -I http://app.example.com
curl https://app.example.comcaddy validate ends with Valid configuration. In the test, HTTP answered 308 to https:// and HTTPS returned the whoami response with X-Forwarded-For filled in. Caddy requests the certificate, renews it and redirects without a single extra line.
The Compose file mounts the conf folder, not the file. The official image page warns against mounting the Caddyfile directly. In the test with the file mounted, a sed -i replaced the file on disk, the container kept reading the old one and caddy reload did not apply the change. With the folder mounted, the same edit went in on the next reload.
The same service behind Traefik
mkdir -p ~/traefik && cd ~/traefikAPP_DOMAIN=app.example.com
[email protected]services:
traefik:
image: traefik:v3.8.0
restart: unless-stopped
command:
- --providers.docker=true
- --providers.docker.exposedbydefault=false
- --entrypoints.web.address=:80
- --entrypoints.web.http.redirections.entrypoint.to=websecure
- --entrypoints.web.http.redirections.entrypoint.scheme=https
- --entrypoints.websecure.address=:443
- --certificatesresolvers.le.acme.email=${ACME_EMAIL}
- --certificatesresolvers.le.acme.storage=/letsencrypt/acme.json
- --certificatesresolvers.le.acme.tlschallenge=true
ports:
- "80:80"
- "443:443"
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
- letsencrypt:/letsencrypt
whoami:
image: traefik/whoami:v1.12.0
restart: unless-stopped
labels:
- traefik.enable=true
- traefik.http.routers.whoami.rule=Host(`${APP_DOMAIN}`)
- traefik.http.routers.whoami.entrypoints=websecure
- traefik.http.routers.whoami.tls.certresolver=le
volumes:
letsencrypt:docker compose config -q
docker compose up -d
docker compose logs traefik
curl -I http://app.example.com
curl https://app.example.comIn the test, curl -I got a 308 to https:// (a plain GET gets 301) and HTTPS returned the whoami response. The flags under command are the static configuration: entry points, the redirect and the certificate resolver. Changing one of them recreates the Traefik container. Labels are the dynamic configuration and apply as soon as the service's container starts.
Replace ACME_EMAIL with an address of your own. With an example.com address, Let's Encrypt refused the account and the Traefik log showed contact email has forbidden domain "example.com".
Adding a second service
This is where the two differ most. With Traefik, the route travels with the service. Add this to docker-compose.yml, under services:
api:
image: traefik/whoami:v1.12.0
restart: unless-stopped
labels:
- traefik.enable=true
- traefik.http.routers.api.rule=Host(`api.example.com`)
- traefik.http.routers.api.entrypoints=websecure
- traefik.http.routers.api.tls.certresolver=ledocker compose up -d
curl https://api.example.comIn the test, up -d created only the new container, the Traefik container kept the same start time and the domain answered 200 right after.
With Caddy there are two files. The service goes into docker-compose.yml, with no labels:
api:
image: traefik/whoami:v1.12.0
restart: unless-stoppedAnd the domain goes at the end of conf/Caddyfile:
api.example.com {
reverse_proxy api:80
}docker compose up -d
docker compose exec -w /etc/caddy caddy caddy reload
curl https://api.example.comBefore the reload, the new domain did not even complete the TLS handshake. After it, the domain answered 200 and the Caddy container did not restart. A typo does not take anything down either: with an unclosed block in the file, the reload answered syntax error: unexpected token '{', expecting '}' and the site already online kept returning 200.
Security: the Docker socket
Traefik only discovers containers because it reads the Docker socket. Its documentation warns that if Traefik is attacked, the attacker might get access to the host, and the Docker documentation says only trusted users should be allowed to control the daemon.
The :ro on the volume does not change that. It protects the socket file, but the API still accepts any command. In the test, a container with the socket mounted read-only stopped another one:
docker run --rm -v /var/run/docker.sock:/var/run/docker.sock:ro docker:29.10.1-cli docker stop traefik-api-1docker compose up -d brings the service back.
To reduce the risk, the Traefik documentation suggests putting a filter between Traefik and the socket, such as docker-socket-proxy, which can allow read access to containers only.
The Caddy in this guide never touches the socket. What it has is an admin API on localhost:2019, inside the container. In the test it answered on 127.0.0.1:2019 through docker compose exec and refused the connection from outside, because the port is not published. If you want labels with Caddy, there is caddy-docker-proxy, which needs the socket again.
HTTPS and HTTP/3
With Caddy, every domain in the Caddyfile gets a certificate. It tries Let's Encrypt and, if that fails, ZeroSSL, with no configuration. The certificates live in the caddy_data volume.
With Traefik, each router needs the tls.certresolver=le label, and the certificates live in acme.json in the letsencrypt volume. Until the certificate is issued, Traefik serves the self-signed TRAEFIK DEFAULT CERT and the browser shows a security warning. If that happens, the reason is in docker compose logs traefik.
Caddy advertises HTTP/3 from the first response (alt-svc: h3=":443"), as long as 443/udp is published. With Traefik, the same header only showed up after adding --entrypoints.websecure.http3=true to command and "443:443/udp" to ports.
When to choose each one
Stay with Caddy if the VPS runs a few services that rarely change. The configuration is short, HTTPS needs nothing and no container exposed to the internet can see the Docker socket.
Go with Traefik if containers start and stop often, if deploys are automated or if each project has to carry its own route in its Compose file. In exchange for not touching the proxy on every new service, you accept more configuration and the care the socket requires.
With a panel, the choice is already made. Coolify uses Traefik by default and accepts Caddy as an alternative, and Dokploy uses Traefik. The comparison Coolify vs Dokploy covers that decision.
What was left out of the test
The test ran on a virtual machine with no public IP. Real DNS and the Let's Encrypt certificate were left out for both: Caddy used its internal certificate authority, with the same Caddyfile, and Traefik stayed on the default certificate. For HTTP/3, only the alt-svc header was checked, with no real QUIC connection. The Traefik dashboard, docker-socket-proxy, caddy-docker-proxy and performance under load were not tested either. Memory was measured on a second virtual machine, arm64, with the same files.
Next steps
- If Caddy answers
502, the guide Fix Caddy 502 Bad Gateway and HTTPS errors with Docker covers the causes. - To see Caddy in front of a real application, follow How to install Portainer with Docker and Caddy on a VPS.
- To pick a server, see the Docker VPS and Linux VPS plans, with Ubuntu 24.04. If you would rather use a panel, there is the Coolify VPS.