%%
date:: [[2024-01-16]]
parent::
%%
# [[Traefik]]
[site](https://traefik.io/traefik/) | [repo](https://github.com/traefik/traefik)
Traefik is a modern [[HTTP]] [[Reverse Proxy]] and [[Load Balancer]] that automatically creates routes that connect your [[Microservices|microservices]] to the outside world, saving you the effort of doing it manually.
It works well with [[Container Orchestration Engines|orchestrators]] like [[Kubernetes]] and [[Docker Swarm]], supports multiple [[Load Balancer|load balancing]] algorithms, and uses [[Let's Encrypt]] for wildcard [[SSL]] certificate support.
![[traefik-automatic-routing.png]]
*Automatic routing with Traefik* [^github]
Traefik also has a simple web UI to see everything at a glance:
![[traefik-web-ui.png]]
*Simple HTML frontend for Traefik* [^github]
## Why use it
The big thing is that it's dynamic. Traefik watches [[Docker]] or [[Kubernetes]] and reconfigures itself when containers come and go. You slap a label on a container and it just gets picked up, no config files to edit, no reload.
- Automatic service discovery, so no hand-maintained upstream lists
- Free [[SSL]] via [[Let's Encrypt]], including auto-renewal (this is the main selling point for a lot of people)
- One entry point for everything: `grafana.example.com` and `app.example.com` through the same proxy on 80/443
- Middleware for auth, rate limiting, retries, redirects, header rewriting
- Ships with [[Prometheus]] metrics and [[OpenTelemetry]] traces, so it's easy to point at [[Grafana]]
## Who uses it
- Homelabbers. Traefik + [[Docker]] Compose is pretty much the default way to expose a self-hosted stack over HTTPS.
- Platform/DevOps teams on [[Kubernetes]], as an ingress controller. It's the default ingress in [[k3s]], so if you run k3s you're already using it.
- Anyone with enough service churn that static proxy config becomes a chore.
## When not to
If you've got a handful of stable services and nothing is moving around, [[Nginx]] or [[Caddy]] is simpler. Traefik's config model (entrypoints, routers, services, middlewares, providers) takes a while to click, and the v1 to v2 to v3 changes mean half the tutorials out there are for the wrong version. Always check which one a guide targets before following it.
## Content I've created
- In [[GOH 28 - OpenTelemetry metrics with Traefik|Grafana Office Hours - OpenTelemetry metrics with Traefik]], I talked to [[Immánuel Fodor]] about how Traefik works well with [[OpenTelemetry]].
%%
## People
- [[Immánuel Fodor]] is someone I know from Traefik.
%%
[^github]: Automatic routing with Traefik. https://github.com/traefik/traefik