Skip to content

Traefik

Traefik is a modern reverse proxy and load balancer often used in containerized environments like [[Docker]]^[400-devops-03-containerization-traefik.md].

It is frequently discussed in the context of DevOps for its ability to dynamically configure itself based on container labels, streamlining the management of microservices^[400-devops-03-containerization-traefik.md].

Configuration via Docker Labels

Traefik integrates with [[Docker]] primarily through the use of labels defined within a docker-compose.yml file^[400-devops-03-containerization-traefik.md].

A standard configuration enables the service for Traefik and specifies routing rules, ports, and protocols^[400-devops-03-containerization-traefik.md]. For example:

labels:
  - "traefik.docker.network=web"
  - "traefik.enable=true"
  - "traefik.basic.frontend.rule=Host:domain2.com"
  - "traefik.basic.port=8080"
  - "traefik.basic.protocol=http"

In this configuration: * traefik.docker.network specifies the Docker network Traefik should listen on^[400-devops-03-containerization-traefik.md]. * traefik.enable activates the integration^[400-devops-03-containerization-traefik.md]. * traefik.basic.frontend.rule defines the routing logic (e.g., by hostname)^[400-devops-03-containerization-traefik.md]. * traefik.basic.port and traefik.basic.protocol indicate the target port and protocol to use for the backend service^[400-devops-03-containerization-traefik.md].

Features

  • Load Balancing: Traefik is described as a "New generation LB" (Load Balancer)1.
  • SSL/TLS Automation: It can be integrated with [[Let's Encrypt]] to automatically manage and renew SSL certificates2.

Sources


  1. 新一代LB - Traefik · Docker學習筆記 ^[400-devops-03-containerization-traefik.md] 

  2. [Docker 教學] 用 Traefik 搭配 Let's Encrypt 憑證服務 - YouTube ^[400-devops-03-containerization-traefik.md]