HTTP Middleware Overview¶
Attached to the routers, pieces of middleware are a means of tweaking the requests before they are sent to your service (or before the answer from the services are sent to the clients).
There are several available middlewares in Traefik, some can modify the request, the headers, some are in charge of redirections, some add authentication, and so on.
Middlewares that use the same protocol can be combined into chains to fit every scenario.
Provider Namespace
Be aware of the concept of Providers Namespace described in the Configuration Discovery section. It also applies to Middlewares.
Available HTTP Middlewares¶
Middleware | Purpose | Area |
---|---|---|
AddPrefix | Adds a Path Prefix | Path Modifier |
BasicAuth | Adds Basic Authentication | Security, Authentication |
Buffering | Buffers the request/response | Request Lifecycle |
Chain | Combines multiple pieces of middleware | Misc |
CircuitBreaker | Prevents calling unhealthy services | Request Lifecycle |
Compress | Compresses the response | Content Modifier |
ContentType | Handles Content-Type auto-detection | Misc |
DigestAuth | Adds Digest Authentication | Security, Authentication |
Errors | Defines custom error pages | Request Lifecycle |
ForwardAuth | Delegates Authentication | Security, Authentication |
GrpcWeb | Converts gRPC Web requests to HTTP/2 gRPC requests. | Request |
Headers | Adds / Updates headers | Security |
IPAllowList | Limits the allowed client IPs | Security, Request lifecycle |
InFlightReq | Limits the number of simultaneous connections | Security, Request lifecycle |
PassTLSClientCert | Adds Client Certificates in a Header | Security |
RateLimit | Limits the call frequency | Security, Request lifecycle |
RedirectScheme | Redirects based on scheme | Request lifecycle |
RedirectRegex | Redirects based on regex | Request lifecycle |
ReplacePath | Changes the path of the request | Path Modifier |
ReplacePathRegex | Changes the path of the request | Path Modifier |
Retry | Automatically retries in case of error | Request lifecycle |
StripPrefix | Changes the path of the request | Path Modifier |
StripPrefixRegex | Changes the path of the request | Path Modifier |
Community Middlewares¶
Please take a look at the community-contributed plugins in the plugin catalog.
Using Traefik OSS in Production?
If you are using Traefik at work, consider adding enterprise-grade API gateway capabilities or commercial support for Traefik OSS.
Adding API Gateway capabilities to Traefik OSS is fast and seamless. There's no rip and replace and all configurations remain intact. See it in action via this short video.