How to use Traefik as a reverse proxy for containers
Updated 10/23/2026
Traefik is a reverse proxy built for containers: it discovers services automatically and gets them HTTPS certificates with no manual configuration. Perfect when you run multiple apps on one server.
1. The Traefik service in Compose
services:
traefik:
image: traefik:v3.0
command:
- "--providers.docker=true"
- "--entrypoints.web.address=:80"
- "--entrypoints.websecure.address=:443"
- "[email protected]"
- "--certificatesresolvers.le.acme.storage=/acme.json"
- "--certificatesresolvers.le.acme.httpchallenge.entrypoint=web"
ports:
- "80:80"
- "443:443"
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
- ./acme.json:/acme.json
2. Label the app
Add labels to your service so Traefik knows where to send traffic:
app:
image: my-app
labels:
- "traefik.http.routers.app.rule=Host(`example.com`)"
- "traefik.http.routers.app.tls.certresolver=le"
3. Start
docker compose up -d
Traefik detects the app, exposes it on the given domain and automatically obtains an HTTPS certificate. For the Nginx version, see Nginx as a reverse proxy.
Put this guide into practice on your own VPS
EU cloud servers, billed hourly, ready in minutes, with one-click installs for dozens of apps.
See pricingRelated tutorials
How to run your own private Docker registry
Host your own Docker images on a private server, without depending on external services.
Updated 10/23/2026Docker & containersHow to read logs and debug Docker containers
When a container fails to start or stops on its own, the logs tell you why. Here is how to read and debug them.
Updated 10/23/2026Docker & containersHow to free up disk space used by Docker
Images, stopped containers and orphaned volumes can fill your disk. Here is how to clean them up safely.
Updated 10/23/2026