This folder contains a production-ready Traefik configuration for the Universus monorepo. It provides:
- Centralized HTTP/HTTPS routing for all services (frontend, backend, admin, bots, email, observability, etc.)
- Automatic service discovery via Docker labels
- Health checks, sticky sessions, and security best practices
- Built-in dashboard for monitoring
traefik.yml— Main static config (entrypoints, providers, dashboard, logging, ACME)dynamic.yml— Dynamic config (middlewares, advanced routing, can be extended).gitignore— Ignores ACME cert storagedocker-compose.yml— Example for local dev (see below)
- Traefik runs as a container, listening on ports 80/443.
- All other services are started as Docker containers with proper labels.
- Traefik auto-discovers services and routes traffic based on labels.
- The dashboard is available at
/dashboard(see below).
version: '3.8'
services:
traefik:
image: traefik:v3.0
command:
- --configFile=/etc/traefik/traefik.yml
ports:
- "80:80"
- "443:443"
- "8080:8080" # Dashboard (dev only)
volumes:
- ./traefik.yml:/etc/traefik/traefik.yml:ro
- ./dynamic.yml:/etc/traefik/dynamic.yml:ro
- ./acme.json:/acme.json
- /var/run/docker.sock:/var/run/docker.sock:ro
restart: unless-stopped
networks:
- universus
frontend:
build: ../frontend
labels:
- "traefik.enable=true"
- "traefik.http.routers.frontend.rule=Host(`localhost`) || Host(`yourdomain.com`)"
- "traefik.http.services.frontend.loadbalancer.server.port=80"
networks:
- universus
backend:
build: ../backend
labels:
- "traefik.enable=true"
- "traefik.http.routers.backend.rule=Host(`api.localhost`) || Host(`api.yourdomain.com`)"
- "traefik.http.services.backend.loadbalancer.server.port=3000"
networks:
- universus
backend-admin-service:
build: ../backend-admin-service
labels:
- "traefik.enable=true"
- "traefik.http.routers.admin.rule=Host(`admin.localhost`) || Host(`admin.yourdomain.com`)"
- "traefik.http.services.admin.loadbalancer.server.port=3001"
networks:
- universus
backend-bot-service:
build: ../backend-bot-service
labels:
- "traefik.enable=true"
- "traefik.http.routers.bot.rule=Host(`bot.localhost`) || Host(`bot.yourdomain.com`)"
- "traefik.http.services.bot.loadbalancer.server.port=3002"
networks:
- universus
email-delivery-service:
build: ../email-delivery-service
labels:
- "traefik.enable=true"
- "traefik.http.routers.email.rule=Host(`email.localhost`) || Host(`email.yourdomain.com`)"
- "traefik.http.services.email.loadbalancer.server.port=3003"
networks:
- universus
observability-service:
build: ../observability-service
labels:
- "traefik.enable=true"
- "traefik.http.routers.observability.rule=Host(`obs.localhost`) || Host(`obs.yourdomain.com`)"
- "traefik.http.services.observability.loadbalancer.server.port=3004"
networks:
- universus
# Add other services (db, redis, rabbitmq) as needed, but usually not exposed via Traefik
networks:
universus:
driver: bridge
- The Traefik dashboard is now protected by HTTP Basic Auth and only accessible to platform admins.
- Access at
http://traefik.localhost:8080/dashboard/(or your internal admin domain). - By default, the dashboard is not exposed to the public internet.
- Credentials are set in
dynamic.ymlunder thedashboard-authmiddleware. Replace the password hash with your own! - To generate a password hash, use:
and copy the output to replace the example hash in
htpasswd -nb admin yourpassworddynamic.yml. - You may also restrict access by IP or use a more advanced auth provider (see Traefik docs).
- Do not expose port 8080 to the public.
- Add new services to
docker-compose.ymlwith propertraefik.http.routersandtraefik.http.serviceslabels. - See Traefik docs for advanced routing, middlewares, and security.
- Automatic Let's Encrypt is fully integrated!
- Traefik will request and renew certificates for your real domains automatically.
- To enable:
- Set your real email in
traefik.ymlundercertificatesResolvers.letsencrypt.acme.email. - Set your real domain(s) in the
Host(...)rules indocker-compose.ymllabels for each service. - Make sure ports 80 and 443 are open and forwarded to your server.
- Run
./init-acme.shonce to createacme.jsonwith secure permissions. - Start Traefik with
docker-compose up.
- Set your real email in
- Traefik will handle all certificate requests, renewals, and storage in
acme.json. - For local dev, use self-signed or disable HTTPS (see Traefik docs).
- In
traefik.yml, set:certificatesResolvers: letsencrypt: acme: email: "[email protected]" storage: acme.json httpChallenge: entryPoint: web
- In
docker-compose.yml, for your service:labels: - "traefik.enable=true" - "traefik.http.routers.frontend.rule=Host(`yourdomain.com`)" - "traefik.http.routers.frontend.entrypoints=web,websecure" - "traefik.http.routers.frontend.tls.certresolver=letsencrypt" - "traefik.http.services.frontend.loadbalancer.server.port=80"
- Traefik will automatically provision and renew the cert for
yourdomain.com.
- Run
./init-acme.shin this folder before starting Traefik for the first time. - This creates
acme.jsonwith the correct permissions (required for cert storage).
- Check Traefik logs for ACME/cert errors.
- Make sure your domain’s DNS points to your server and ports 80/443 are open.
- See Traefik ACME docs for advanced options (DNS challenge, wildcard certs, etc).
- Check Traefik logs (
docker logs traefik) - Visit the dashboard for live status and errors
- See Traefik Community for help
- Do not expose the dashboard or
insecure: truein production. - Use strong passwords and firewalls for admin endpoints.
This setup is ready for local dev and can be extended for production.