A Traefik middleware plugins developed using the Go language.
The goal is to match the behavior of X-Real-Ip
of nginx.
For each plugin, the Traefik static configuration must define the module name (as is usual for Go packages).
The following declaration (given here in YAML) defines a plugin:
# Static configuration
pilot:
token: xxxxx
experimental:
plugins:
xrealip:
moduleName: github.com/tommoulard/xrealip
version: v0.0.1
Here is an example of a file provider dynamic configuration (given here in YAML), where the interesting part is the http.middlewares
section:
# Dynamic configuration
http:
routers:
my-router:
rule: host(`demo.localhost`)
service: service-foo
entryPoints:
- web
middlewares:
- xrealip
services:
service-foo:
loadBalancer:
servers:
- url: http://127.0.0.1:5000
middlewares:
xrealip:
plugin:
xrealip:
from:
- 127.0.0.1
header: Cf-Connecting-Ip
resursive: true
The configuration matches the one given by nginx itself:
from
is equivalent asset_real_ip_from
header
is equivalent asreal_ip_header
(defaultX-Forwarded-For
)recursive
is equivalent asreal_ip_recursive
You can find a more in depth configuration description on the nginx doc itself.