A Traefik middleware plugin that extracts the real client IP address from various HTTP headers.
Traefik Real IP extracts and validates the actual client IP address from commonly used headers such as X-Forwarded-For, X-Real-IP, and Cf-Connecting-Ip. This plugin is particularly useful when Traefik is behind a CDN, proxy, or load balancer like Cloudflare.
Cf-Connecting-Ip, Eo-Connecting-Ip, X-Real-IP, and X-Forwarded-For headersThe easiest way to install this plugin is through the Traefik Plugin Catalog.
Add the plugin to your Traefik static configuration:
experimental:plugins:traefik-real-ip:moduleName: github.com/zekihan/traefik-real-ipversion: v0.1.19
# Static configurationexperimental:plugins:traefik-real-ip:moduleName: github.com/zekihan/traefik-real-ipversion: v0.1.19
# Dynamic configurationhttp:middlewares:traefik-real-ip:plugin:traefik-real-ip:thrustLocal: truethrustCloudFlare: truethrustEdgeOne: falsetrustedIPs:- "1.2.3.4/32"- "10.0.0.0/8"logLevel: info
| Option | Type | Default | Description |
|---|---|---|---|
thrustLocal | boolean | true | Trust local and private IP ranges |
thrustCloudFlare | boolean | true | Trust Cloudflare IP ranges |
thrustEdgeOne | boolean | false | Trust EdgeOne IP ranges |
trustedIPs | array of strings | [] | Additional IP ranges to trust in CIDR notation |
logLevel | string | info | Log level (debug, info, warn, error) |
Cf-Connecting-Ip, Eo-Connecting-Ip, X-Real-IP, then X-Forwarded-For.X-Is-Trusted: yes|no header indicating if the source was trustedA Docker Compose setup is provided in the testing folder to test the plugin locally:
cd testingdocker-compose up -d
go test ./...
This project is licensed under the MIT License - see the LICENSE file for details.