Skip to main content

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.

TCP Middlewares

Controlling TCP Connections

Configuration Example

# As a Docker Label
whoami:
  image: traefik/whoami
  labels:
    # Create a middleware named `foo-ip-allowlist`
    - "traefik.tcp.middlewares.foo-ip-allowlist.ipallowlist.sourcerange=127.0.0.1/32, 192.168.1.7"
    # Apply the middleware named `foo-ip-allowlist` to the router named `router1`
    - "traefik.tcp.routers.router1.middlewares=foo-ip-allowlist@docker"

Available TCP Middlewares

MiddlewarePurposeArea
InFlightConnLimits simultaneous connectionsSecurity, Request lifecycle
IPAllowListLimit allowed client IPsSecurity, Request lifecycle

TCP vs HTTP Middlewares

TCP middlewares operate at the transport layer (Layer 4) and have different capabilities compared to HTTP middlewares:
  • TCP middlewares work with raw TCP connections
  • HTTP middlewares can inspect and modify HTTP requests/responses
TCP middlewares cannot inspect HTTP-specific data like headers, methods, or paths. For HTTP traffic, use HTTP middlewares instead.