Situatie
Summary
We’ll create a docker-compose.yml with Traefik v2 as the edge proxy that routes service1.localhost and service2.localhost to containers and obtains TLS certs using the local Traefik ACME (for public domains you’d use real DNS; for local dev we’ll use --docker provider + self-signed or mkcert).
Note: Browsers block Let’s Encrypt on *.localhost. For true HTTPS locally use mkcert + mount certs, or use traefik with TLS using mkcert certificates.
Solutie
Files
-
docker-compose.yml -
traefik/traefik.yml -
traefik/acme.json -
service1/Dockerfile,service2/Dockerfile
Example docker-compose.yml
Quick steps
-
Create
acme.jsonand set permissions
-
Create simple services (e.g., minimal Node or Python apps)
service1/Dockerfile(example Python Flask):
service1/app.py:
-
Map local hostnames to 127.0.0.1
Edit/etc/hosts(sudo) and add:
-
Start
-
Open
https://service1.local/(if using real certs) — for local dev usemkcertto generate certs and mount them into Traefik and configure TLS intraefik.yml.
Troubleshooting & notes
-
Let’s Encrypt cannot issue certs for
*.local; usemkcertor use a public DNS/mapped domain for real TLS -
If Traefik fails to start, check logs:
docker compose logs traefik -
For advanced routing add middleware labels (rate-limit, basic auth)
-
This pattern scales to many services and matches production reverse-proxy behavior.
Leave A Comment?