Configuration

Traefik is configured by editing the traefik.yml static configuration file and pushing any change to it to the main branch of the repository will trigger a Docker image build that applies the new configuration.

Configuration (traefik.yml)

global:
  checkNewVersion: false
  sendAnonymousUsage: false

log:
  level: INFO

api:
  insecure: true
  dashboard: true

entryPoints:
  http:
    address: ":80"
  https:
    address: ":443"
  metrics:
    address: ":8081"

providers:
  docker:
    endpoint: "unix:///var/run/docker.sock"
    exposedByDefault: false

metrics:
  prometheus:
    entryPoint: metrics
    addEntryPointsLabels: true
    addServicesLabels: true
    addRoutersLabels: true
    buckets:
      - 0.1
      - 0.3
      - 1.2
      - 5.0

Configuration Options Explained

### global

  • checkNewVersion: Set to false to disable automatic version checks.

  • sendAnonymousUsage: Set to false to prevent sending anonymous usage statistics.

### log

  • level: Logging level. Common values: DEBUG, INFO, WARN, ERROR, FATAL.

### api

  • insecure: Enables the API and dashboard over plain HTTP. Useful for local development.

  • dashboard: Enables the web-based dashboard.

### entryPoints

Defines the ports on which Traefik listens.

  • http: Listens on port 80.

  • https: Listens on port 443.

  • metrics: Custom entry point on port 8081 for Prometheus metrics.

### providers

Configuration for dynamic configuration sources.

  • docker:

    • endpoint: The Docker socket Traefik watches for container changes. Usually “unix:///var/run/docker.sock”.

    • exposedByDefault: When false, containers must explicitly opt-in to be exposed using Docker labels.

### metrics

Enables metric collection.

  • prometheus:

    • entryPoint: The name of the entry point that exposes the metrics endpoint (e.g., metrics).

    • addEntryPointsLabels: Adds labels for entry points in Prometheus metrics.

    • addServicesLabels: Adds labels for services in Prometheus metrics.

    • addRoutersLabels: Adds labels for routers in Prometheus metrics.

    • buckets: Histogram buckets for request durations (in seconds).