If Traefik is behind Cloudflare, it won't be able to get the real IP from the external client by checking the remote IP address.
This plugin solves this issue by overwriting the X-Real-IP with an IP from the Cf-Connecting-IP header. The real IP will be the Cf-Connecting-IP if request is come from cloudflare ( truest ip in configuration file).
Supported configurations per body
Setting | Allowed values | Required | Description |
---|---|---|---|
trustip | []string | Yes | IP or IP range to trust |
pilot:
token: xxxx
experimental:
plugins:
traefik-real-ip:
modulename: github.com/vincentinttsh/cloudflareip
version: v1.0.0
http:
routers:
my-router:
rule: Path(`/whoami`)
service: service-whoami
entryPoints:
- http
middlewares:
- cloudflareip
services:
service-whoami:
loadBalancer:
servers:
- url: http://127.0.0.1:5000
middlewares:
cloudflareip:
plugin:
cloudflareip:
trustip:
- "1.1.1.1/24"