Docs / Web Servers / How to Set Up Traefik for Container-Based Routing

How to Set Up Traefik for Container-Based Routing

By Admin · Mar 1, 2026 · Updated Apr 24, 2026 · 28 views · 2 min read

How to Set Up Traefik for Container-Based Routing

Traefik is a modern reverse proxy and load balancer designed for container environments. It automatically discovers services and routes traffic on your Breeze server without manual configuration updates.

Deploying Traefik with Docker Compose

services:
  traefik:
    image: traefik:v3.1
    command:
      - "--api.dashboard=true"
      - "--providers.docker=true"
      - "--providers.docker.exposedbydefault=false"
      - "--entrypoints.web.address=:80"
      - "--entrypoints.websecure.address=:443"
      - "--certificatesresolvers.letsencrypt.acme.email=admin@yourdomain.com"
      - "--certificatesresolvers.letsencrypt.acme.storage=/letsencrypt/acme.json"
      - "--certificatesresolvers.letsencrypt.acme.httpchallenge.entrypoint=web"
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro
      - letsencrypt:/letsencrypt

volumes:
  letsencrypt:

Routing to Application Services

Add labels to your application containers for automatic routing:

services:
  webapp:
    image: myapp:latest
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.webapp.rule=Host(`app.yourdomain.com`)"
      - "traefik.http.routers.webapp.entrypoints=websecure"
      - "traefik.http.routers.webapp.tls.certresolver=letsencrypt"
      - "traefik.http.services.webapp.loadbalancer.server.port=8080"

Adding Middleware

labels:
  - "traefik.http.middlewares.ratelimit.ratelimit.average=100"
  - "traefik.http.middlewares.ratelimit.ratelimit.burst=50"
  - "traefik.http.routers.webapp.middlewares=ratelimit"

Key Benefits

  • Automatic service discovery from Docker labels
  • Built-in Let's Encrypt certificate management
  • Dashboard for real-time traffic visualization
  • Middleware for rate limiting, authentication, and headers
  • Zero-downtime configuration reloads

Was this article helpful?