DevOps

Traefik

Traefik is a cloud-native reverse proxy and edge router that discovers services in Docker and Kubernetes and configures routes itself.

What it is

Traefik was created by Emile Vauge (Traefik Labs) and first released in 2015. It is a reverse proxy and load balancer built for microservices: it connects to providers (Docker, Kubernetes, Consul, files) and builds routes itself as services appear or disappear.

Routes are set by labels on containers or Kubernetes resources (Ingress, IngressRoute). Core concepts: entrypoints (ports Traefik listens on), routers (rules by host and path), middlewares (redirects, auth, rate limit) and services.

Traefik can get Let's Encrypt certificates automatically, has a built-in dashboard and is widely used as an ingress controller in Kubernetes.

Use it when

  • You have many containers that appear and disappear dynamically.
  • You need an ingress controller for Kubernetes.
  • You want to manage routes through labels in Docker Compose.

Avoid it when

  • A simple static site or one app: Caddy or nginx are simpler.
  • You need deep tuning of caching and static serving: nginx is stronger.

Key concepts

Provider
A source of configuration and service discovery: Docker, Kubernetes, a file.
Entrypoint
A port and protocol Traefik listens on (for example web on 80, websecure on 443).
Router
A rule that ties a request (Host, PathPrefix) to a service.
Middleware
An intermediate processing step: redirect, basic auth, rate limit, compression.

Example

Traefik in Docker Compose discovers the app container and routes to it by host.

Interview questions

  1. 1. What is Traefik's main idea?

    Dynamic configuration: it reads from Docker or Kubernetes which services exist and builds routes itself. No manual config edits and proxy restarts on every deploy.

  2. 2. What are a router, a service and a middleware?

    A router defines the matching rule for a request, a service describes the backend to forward to, and a middleware is a step on the way, such as a redirect or authentication.

  3. 3. Traefik or nginx?

    Traefik is better in dynamic container environments with auto discovery and certificates. nginx is stronger at static serving, caching and fine tuning, but its config is static.

Logos belong to their owners and are used for identification only. Icons: Simple Icons (CC0), Devicon (MIT).