Top Related Projects
Traefik Mesh - Simpler Service Mesh
The official NGINX Open Source repository.
HAProxy Load Balancer's development branch (mirror of git.haproxy.org)
Cloud-native high-performance edge/middle/service proxy
🦍 The Cloud-Native API Gateway and AI Gateway.
Consul Load-Balancing made simple
Quick Overview
Traefik is a modern HTTP reverse proxy and load balancer that makes deploying microservices easy. It integrates with existing infrastructure components and automatically configures itself. Traefik supports multiple providers (Docker, Kubernetes, etc.) and offers features like automatic HTTPS, metrics, and tracing.
Pros
- Easy to set up and configure, with automatic service discovery
- Supports multiple providers and integrates well with container orchestration platforms
- Offers dynamic configuration and real-time updates without restarts
- Provides built-in monitoring, metrics, and tracing capabilities
Cons
- Learning curve for advanced configurations and custom middleware
- Documentation can be overwhelming for beginners
- Limited built-in caching capabilities compared to some other reverse proxies
- Performance may be slightly lower than more specialized reverse proxies in certain scenarios
Getting Started
To get started with Traefik using Docker:
- Create a
docker-compose.yml
file:
version: '3'
services:
traefik:
image: traefik:v2.9
command:
- "--api.insecure=true"
- "--providers.docker=true"
ports:
- "80:80"
- "8080:8080"
volumes:
- /var/run/docker.sock:/var/run/docker.sock
whoami:
image: traefik/whoami
labels:
- "traefik.http.routers.whoami.rule=Host(`whoami.localhost`)"
- Run the following command:
docker-compose up -d
- Access the Traefik dashboard at
http://localhost:8080
and the whoami service athttp://whoami.localhost
.
This setup creates a basic Traefik instance that discovers and routes traffic to a simple "whoami" service. The Traefik dashboard is exposed on port 8080, allowing you to monitor and manage your services.
Competitor Comparisons
Traefik Mesh - Simpler Service Mesh
Pros of Mesh
- Specifically designed for service mesh architecture, offering advanced features like traffic splitting and circuit breaking
- Provides deeper integration with Kubernetes, including automatic sidecar injection
- Supports multi-cluster deployments and cross-cluster communication
Cons of Mesh
- Less mature and has a smaller community compared to Traefik
- More complex to set up and configure, especially for simpler use cases
- Limited support for non-Kubernetes environments
Code Comparison
Traefik configuration example:
http:
routers:
my-router:
rule: "Host(`example.com`)"
service: my-service
Mesh configuration example:
apiVersion: traefik.containo.us/v1alpha1
kind: TraefikService
metadata:
name: my-service
spec:
weighted:
services:
- name: service-v1
weight: 80
- name: service-v2
weight: 20
The Traefik example shows a simple HTTP router configuration, while the Mesh example demonstrates a more advanced traffic splitting setup between two service versions.
The official NGINX Open Source repository.
Pros of Nginx
- Highly efficient and lightweight, optimized for high-performance scenarios
- Extensive documentation and large community support
- Versatile, serving as a web server, reverse proxy, and load balancer
Cons of Nginx
- Configuration can be complex, especially for beginners
- Limited built-in features for dynamic configuration and service discovery
- Requires manual intervention for SSL certificate management
Code Comparison
Nginx configuration example:
server {
listen 80;
server_name example.com;
location / {
proxy_pass http://backend;
}
}
Traefik configuration example:
http:
routers:
my-router:
rule: "Host(`example.com`)"
service: my-service
services:
my-service:
loadBalancer:
servers:
- url: "http://backend"
Traefik offers a more declarative and dynamic configuration approach, while Nginx requires more manual setup but provides fine-grained control over the configuration.
Both projects are widely used and have their strengths. Nginx excels in high-performance scenarios and traditional setups, while Traefik shines in dynamic environments and container orchestration platforms. The choice between them depends on specific use cases and infrastructure requirements.
HAProxy Load Balancer's development branch (mirror of git.haproxy.org)
Pros of HAProxy
- Excellent performance and low resource usage
- Highly configurable with advanced load balancing algorithms
- Mature and battle-tested in production environments
Cons of HAProxy
- Steeper learning curve and more complex configuration
- Limited built-in service discovery and dynamic configuration options
- Less focus on modern cloud-native features out of the box
Code Comparison
HAProxy configuration example:
frontend http_front
bind *:80
default_backend http_back
backend http_back
balance roundrobin
server server1 192.168.1.10:80 check
server server2 192.168.1.11:80 check
Traefik configuration example:
http:
routers:
my-router:
rule: "Host(`example.com`)"
service: my-service
services:
my-service:
loadBalancer:
servers:
- url: "http://192.168.1.10:80"
- url: "http://192.168.1.11:80"
HAProxy excels in performance and fine-grained control, making it ideal for complex load balancing scenarios. Traefik, on the other hand, offers easier configuration and better integration with modern container orchestration platforms, making it more suitable for cloud-native environments.
Cloud-native high-performance edge/middle/service proxy
Pros of Envoy
- More extensive feature set and flexibility for complex networking scenarios
- Better performance and lower latency in high-traffic environments
- Stronger support for service mesh architectures
Cons of Envoy
- Steeper learning curve and more complex configuration
- Less user-friendly for simple reverse proxy use cases
- Requires more resources to run compared to Traefik
Code Comparison
Traefik configuration (YAML):
http:
routers:
my-router:
rule: "Host(`example.com`)"
service: my-service
services:
my-service:
loadBalancer:
servers:
- url: "http://backend1:8080"
- url: "http://backend2:8080"
Envoy configuration (YAML):
static_resources:
listeners:
- address:
socket_address:
address: 0.0.0.0
port_value: 80
filter_chains:
- filters:
- name: envoy.filters.network.http_connection_manager
typed_config:
"@type": type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager
codec_type: auto
stat_prefix: ingress_http
route_config:
name: local_route
virtual_hosts:
- name: backend
domains:
- "*"
routes:
- match:
prefix: "/"
route:
cluster: backend_service
clusters:
- name: backend_service
connect_timeout: 0.25s
type: strict_dns
lb_policy: round_robin
load_assignment:
cluster_name: backend_service
endpoints:
- lb_endpoints:
- endpoint:
address:
socket_address:
address: backend1
port_value: 8080
- endpoint:
address:
socket_address:
address: backend2
port_value: 8080
🦍 The Cloud-Native API Gateway and AI Gateway.
Pros of Kong
- More extensive plugin ecosystem with a wide range of pre-built and custom plugins
- Better suited for complex, enterprise-level API management scenarios
- Stronger focus on API-specific features like rate limiting, authentication, and transformations
Cons of Kong
- Steeper learning curve and more complex setup compared to Traefik
- Requires a separate database (PostgreSQL or Cassandra) for configuration storage
- Higher resource consumption, especially in larger deployments
Code Comparison
Kong configuration example:
services:
- name: my-service
url: http://localhost:3000
routes:
- name: my-route
paths:
- /api
Traefik configuration example:
http:
routers:
my-router:
rule: "Path(`/api`)"
service: my-service
services:
my-service:
loadBalancer:
servers:
- url: "http://localhost:3000"
Both Kong and Traefik are powerful API gateways and reverse proxies, but they have different strengths. Kong excels in complex API management scenarios with its extensive plugin system, while Traefik offers a more straightforward setup and is particularly well-suited for container environments. The choice between them depends on specific project requirements and the level of API management complexity needed.
Consul Load-Balancing made simple
Pros of Fabio
- Simpler configuration and setup, with automatic service discovery
- Lower resource usage and faster performance in some scenarios
- Better suited for microservices architectures using Consul
Cons of Fabio
- Limited feature set compared to Traefik's extensive capabilities
- Less active community and fewer integrations with other tools
- Primarily focused on Consul, which may limit flexibility in some environments
Code Comparison
Fabio route configuration:
urlprefix-/api strip=/api
Traefik equivalent configuration:
http:
routers:
api:
rule: "PathPrefix(`/api`)"
middlewares:
- "strip-prefix"
middlewares:
strip-prefix:
stripPrefix:
prefixes:
- "/api"
Fabio is more concise in this example, reflecting its simpler approach to configuration. Traefik offers more granular control but requires more verbose configuration.
Both Traefik and Fabio are popular reverse proxy and load balancing solutions, but they cater to different use cases. Traefik is more feature-rich and versatile, while Fabio excels in simplicity and performance, especially in Consul-based environments. The choice between them depends on specific project requirements and infrastructure setup.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
Traefik (pronounced traffic) is a modern HTTP reverse proxy and load balancer that makes deploying microservices easy. Traefik integrates with your existing infrastructure components (Docker, Swarm mode, Kubernetes, Consul, Etcd, Rancher v2, Amazon ECS, ...) and configures itself automatically and dynamically. Pointing Traefik at your orchestrator should be the only configuration step you need.
. Overview . Features . Supported backends . Quickstart . Web UI . Documentation .
. Support . Release cycle . Contributing . Maintainers . Credits .
:warning: When migrating to a new major version of Traefik, please refer to the migration guide to ensure a smooth transition and to be aware of any breaking changes.
Overview
Imagine that you have deployed a bunch of microservices with the help of an orchestrator (like Swarm or Kubernetes) or a service registry (like etcd or consul). Now you want users to access these microservices, and you need a reverse proxy.
Traditional reverse-proxies require that you configure each route that will connect paths and subdomains to each microservice. In an environment where you add, remove, kill, upgrade, or scale your services many times a day, the task of keeping the routes up to date becomes tedious.
This is when Traefik can help you!
Traefik listens to your service registry/orchestrator API and instantly generates the routes so your microservices are connected to the outside world -- without further intervention from your part.
Run Traefik and let it do the work for you! (But if you'd rather configure some of your routes manually, Traefik supports that too!)
Features
- Continuously updates its configuration (No restarts!)
- Supports multiple load balancing algorithms
- Provides HTTPS to your microservices by leveraging Let's Encrypt (wildcard certificates support)
- Circuit breakers, retry
- See the magic through its clean web UI
- Websocket, HTTP/2, gRPC ready
- Provides metrics (Rest, Prometheus, Datadog, Statsd, InfluxDB 2.X)
- Keeps access logs (JSON, CLF)
- Fast
- Exposes a Rest API
- Packaged as a single binary file (made with :heart: with go) and available as an official docker image
Supported Backends
Quickstart
To get your hands on Traefik, you can use the 5-Minute Quickstart in our documentation (you will need Docker).
Web UI
You can access the simple HTML frontend of Traefik.
Documentation
You can find the complete documentation of Traefik v3 at https://doc.traefik.io/traefik/.
A collection of contributions around Traefik can be found at https://awesome.traefik.io.
Support
To get community support, you can:
If you need commercial support, please contact Traefik.io by mail: mailto:support@traefik.io.
Download
- Grab the latest binary from the releases page and run it with the sample configuration file:
./traefik --configFile=traefik.toml
- Or use the official tiny Docker image and run it with the sample configuration file:
docker run -d -p 8080:8080 -p 80:80 -v $PWD/traefik.toml:/etc/traefik/traefik.toml traefik
- Or get the sources:
git clone https://github.com/traefik/traefik
Introductory Videos
You can find high level and deep dive videos on videos.traefik.io.
Maintainers
We are strongly promoting a philosophy of openness and sharing, and firmly standing against the elitist closed approach. Being part of the core team should be accessible to anyone who is motivated and want to be part of that journey! This document describes how to be part of the maintainers' team as well as various responsibilities and guidelines for Traefik maintainers. You can also find more information on our process to review pull requests and manage issues in this document.
Contributing
If you'd like to contribute to the project, refer to the contributing documentation.
Please note that this project is released with a Contributor Code of Conduct. By participating in this project, you agree to abide by its terms.
Release Cycle
- We usually release 3/4 new versions (e.g. 1.1.0, 1.2.0, 1.3.0) per year.
- Release Candidates are available before the release (e.g. 1.1.0-rc1, 1.1.0-rc2, 1.1.0-rc3, 1.1.0-rc4, before 1.1.0).
- Bug-fixes (e.g. 1.1.1, 1.1.2, 1.2.1, 1.2.3) are released as needed (no additional features are delivered in those versions, bug-fixes only).
Each version is supported until the next one is released (e.g. 1.1.x will be supported until 1.2.0 is out).
We use Semantic Versioning.
Mailing Lists
- General announcements, new releases: mail at news+subscribe@traefik.io or on the online viewer.
- Security announcements: mail at security+subscribe@traefik.io or on the online viewer.
Credits
Kudos to Peka for his awesome work on the gopher's logo!.
The gopher's logo of Traefik is licensed under the Creative Commons 3.0 Attributions license.
The gopher's logo of Traefik was inspired by the gopher stickers made by Takuya Ueda. The original Go gopher was designed by Renee French.
Top Related Projects
Traefik Mesh - Simpler Service Mesh
The official NGINX Open Source repository.
HAProxy Load Balancer's development branch (mirror of git.haproxy.org)
Cloud-native high-performance edge/middle/service proxy
🦍 The Cloud-Native API Gateway and AI Gateway.
Consul Load-Balancing made simple
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot