Traefik Notes

Key Concepts

Core Components

Entrypoints

Network entry points where Traefik listens for incoming requests.

Routers

Connect incoming requests to services based on defined rules.

Services

Define how to reach backend services that process requests.

Middlewares

Modify requests or responses, adding functionalities like authentication or rate limiting.

Configuration Settings

Static Configuration

Foundational settings that remain constant:

Set through:

Dynamic Configuration

Settings that can be modified on-the-fly:

Use Cases

Common Labels

Port Configuration

traefik.http.services.blue.loadbalancer.server.port=5051

Tells Traefik which port to forward requests to within the container.

Router Rule

traefik.http.routers.myrouter.rule=Host(`example.com`) && PathPrefix(`/api`)

Defines conditions for routing requests to a specific service.

Enable Traefik for a Service

traefik.enable=true

Instructs Traefik to include this container in its routing.

Middleware Application

traefik.http.routers.myrouter.middlewares=auth-middleware

Applies a middleware to a specific router.

Troubleshooting

  1. Check Traefik logs for routing issues.
  2. Verify container health and accessibility.
  3. Ensure labels are correctly defined in Docker Compose.
  4. Confirm network connectivity between Traefik and services.