Documentation Index
Fetch the complete documentation index at: https://mintlify.com/traefik/traefik/llms.txt
Use this file to discover all available pages before exploring further.
Core Concepts
Understanding Traefik’s architecture is key to using it effectively. This guide explains the fundamental building blocks and how they work together.Architecture Overview
Traefik’s architecture is built around five core concepts that work together to route and handle requests:EntryPoints
Network entry points that listen for incoming traffic on specific ports
Routers
Analyze requests and connect them to services based on rules
Services
Define how to reach the actual backend servers
Middleware
Transform requests and responses (auth, headers, rate limiting)
Providers
Discover and configure services automatically from infrastructure
EntryPoints
EntryPoints are the network entry points into Traefik. They define the port which will receive packets, and whether to listen for TCP or UDP.How EntryPoints Work
Think of EntryPoints as the doors to your application. Each door (EntryPoint) listens on a specific port and protocol:web→ Port 80 (HTTP)websecure→ Port 443 (HTTPS)custom→ Any port you define
Configuration Examples
Advanced EntryPoint Features
UDP Support: For protocols like DNS or game serversRouters
Routers are responsible for connecting incoming requests to the services that can handle them. They analyze requests using rules and forward them to the appropriate service.Router Rules
Routers use rules to determine if they should handle a request. Rules can match on:- Host:
Host(example.com) - Path:
Path(/api) - PathPrefix:
PathPrefix(/admin) - Headers:
Headers(Content-Type,application/json) - Method:
Method(GET,POST)
&& (AND) and || (OR):
HTTP Router Example
Docker Labels Example
With Docker, routers are defined using labels:If no entrypoints are specified, the router will accept requests from all defined entrypoints.
Services
Services define how to reach the actual backend servers that will handle the requests. They configure load balancing, health checks, and server addresses.Load Balancer Configuration
Each service has a load balancer that can distribute traffic across multiple servers:Load Balancing Algorithms
Traefik supports multiple load balancing strategies:- Round Robin (default): Distributes requests evenly
- Weighted Round Robin: Based on server weights
- Least Connections: Routes to server with fewest active connections
Health Checks
Configure health checks to ensure traffic only goes to healthy servers:Middleware
Middleware are transformers that can modify requests before they reach the service, or modify responses before they return to the client.Common Middleware Types
Authentication
BasicAuth, DigestAuth, ForwardAuth for securing routes
Rate Limiting
Protect your services from abuse and control traffic
Headers
Add, modify, or remove HTTP headers
Path Manipulation
StripPrefix, AddPrefix, ReplacePath for URL rewriting
Retry
Automatically retry failed requests
Circuit Breaker
Prevent cascading failures in microservices
Compression
Compress responses to reduce bandwidth
Redirects
Redirect requests based on rules
Middleware Examples
Chaining Middleware
You can chain multiple middleware together:Providers
Providers are the bridge between your infrastructure and Traefik. They automatically discover services and generate configuration dynamically.How Providers Work
Providers continuously watch your infrastructure and update Traefik’s configuration in real-time:- Provider connects to infrastructure (Docker, Kubernetes, etc.)
- Discovers running services and their metadata
- Generates routers, services, and middleware configuration
- Updates Traefik without restart
Available Providers
- Docker
- Kubernetes
- File
- Consul / Etcd
Automatically discovers containers and uses labels for configuration:
You can use multiple providers simultaneously. Traefik will merge the configuration from all sources.
Putting It All Together
Here’s a complete example showing how all concepts work together:Request Flow
Let’s trace a request through Traefik:Request arrives at EntryPoint
A client makes a request to
https://api.example.com/v1/usersThe request arrives at the websecure EntryPoint (port 443)Router matches the request
Traefik checks all routers to find a matchThe
api-router matches because:- Host is
api.example.com✓ - Path starts with
/v1✓ - EntryPoint is
websecure✓
Middleware processes the request
The request passes through middleware chain:
- Authentication middleware validates credentials
- Rate limiting middleware checks request quota
Service forwards to backend
The load balancer in
api-service selects a healthy backend serverRequest is forwarded to http://192.168.1.10:8080/v1/usersConfiguration: Static vs Dynamic
Traefik has two types of configuration:Static Configuration
- Defined at startup (command line, environment variables, or config file)
- Requires restart to change
- Defines: EntryPoints, Providers, API, Log settings
Dynamic Configuration
- Loaded from providers (Docker, Kubernetes, files, etc.)
- Updates automatically without restart
- Defines: Routers, Services, Middleware
Next Steps
Now that you understand Traefik’s core concepts:Installation Guide
Deploy Traefik on your preferred platform
HTTPS & TLS
Configure automatic SSL certificates with Let’s Encrypt
Middleware Reference
Explore all available middleware options
Provider Documentation
Deep dive into provider-specific configuration