Feature request: Prefer an end-user configured IP header when available
For a given Traefik log entry, e.g.:
{
"ClientAddr": "104.22.105.6:10884",
"ClientHost": "104.22.105.6",
"DownstreamContentSize": 0,
"DownstreamStatus": 0,
"Duration": 173108453463,
"OriginContentSize": 0,
"OriginDuration": 171130088445,
"OriginStatus": 0,
"Overhead": 1978365018,
"RequestMethod": "GET",
⋮
"level": "info",
"msg": "",
"origin_Content-Type": "",
"request_Cf-Connecting-Ip": "2607:fb90:6272:c2f0:d4c6:76ff:fed1:bb7b",
"request_Cf-Ipcountry": "US",
"request_Cookie": "REDACTED",
"request_User-Agent": "Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/153.0.0.0 Mobile Safari/537.36",
"request_X-Forwarded-For": "2607:fb90:6272:c2f0:d4c6:76ff:fed1:bb7b",
"request_X-Forwarded-Host": [REDACTED],
"request_X-Forwarded-Proto": "https",
"request_X-Real-Ip": "2607:fb90:6272:c2f0:d4c6:76ff:fed1:bb7b",
"time": "2026-09-18T09:57:46-04:00"
}
When request_Cf-Connecting-Ip is available, it would be useful to optionally use that as the IP for hit/source tallying instead of ClientAddr / ClientHost.
In this example, ClientHost is the Cloudflare proxy (104.22.105.6), while request_Cf-Connecting-Ip contains the actual client IP. For purposes such as counting hits by source IP, using ClientHost would therefore aggregate all Cloudflare traffic together rather than representing the actual visitors.
More generally, though, it would probably be ideal if the "end-user IP header field" could be configured rather than hard-coding Cloudflare's header. For example, a user could specify:
request_Cf-Connecting-Ip
or whatever equivalent header their reverse proxy uses.
The desired behavior would be roughly:
- If a configured end-user IP header exists and contains a value, use that for IP-based tallying/logging.
- Otherwise fall back to the existing
ClientHost/ClientAddrbehavior.
That would make the feature useful across different reverse-proxy configurations while retaining the current behavior as a fallback.
This is relevant more for Traefik logs than for the Crowdsec ones as parsing/enrichment rules can basically obviate the need to use e.g., request_Cf-Connecting-IP downstream.
I went ahead and implemented this locally.
The basic change is an environmental variable IP_SOURCE_HEADER. It lets me tell CrowdSec Manager which Traefik JSON field should be treated as the client IP, rather than always using ClientHost.
For example, with Cloudflare proxies in front of Traefik I can set:
IP_SOURCE_HEADER=request_Cf-Connecting-Ip
and the Manager now uses that value for the client-IP handling, including the dashboard aggregation and the CLIENT IP column in Live Traffic Logs. It still falls back through the existing ClientHost → ClientAddr → ClientIP → IP → RemoteAddr chain when the option isn't configured or when the connection is unproxied.
I deliberately made it generic rather than Cloudflare-specific, since the same situation can come up with Fastly, Akamai, nginx, HAProxy, Envoy, etc., where the original client address may be carried in a proxy-specific or X-Forwarded-* header.
I also left the default as unset, so existing installations retain the current behavior.
I've tested the change against my actual Traefik/Cloudflare setup, including the slightly fun part where the actual client address is IPv6 even though the remote host itself is IPv4-only, and both go test ./... and docker build are clean.
So, as far as I'm concerned, the FR is implemented and working.
I'm not going to spend the time forking the repo and submitting a PR until I know there's actually interest in merging it. If/when you get back to this and want the change upstreamed, I have the working implementation here and can turn it into a proper PR.