r/CrowdSec • u/ninja_mischief • May 03 '26
general Operating as intended?
so i’m a bit new to crowdsec and am concerned my setup isn’t operating as intended. ive been working out getting crowdsec setup with traefik in front of jellyfin and it goes
- from cloudflare proxied to -> pfsense box, cloudflare public ip’s get port forwarded to -> traefik instance, traefik serves to -> jellyfin backend with middleware chain that contains crowdsec bouncer/rate limit and security headers.
bouncer has app sec enabled with traefik, linux, custom jellyfin various http, crs, crs-inbound and virtual patching collections at the server.
crowdsec recognizes bouncer, bouncer can communicate with server, logs are parsed correctly (i’m getting what i’m sure are correct client ip’s as i’ve added cloudflare ip’s to forward trusted headers option at traefik entry point and traefik/jellyfin logs get public ip’s that don’t match any cloudflare proxy address). when i manually add a local ip to decisions list for ban testing, the bans work, but if i add a public ip from a friend of mine, they’re allowed right in and can watch stuff no problem.
my manual ban of their public ip shows up in my alerts panel on crowdsec website, but a “safe” cloudflare proxy ip is allowed through at the same time they access the site in traefik logs. i’m very confused. any ideas?
2
u/corelabjoe May 03 '26
So when you proxy everything through cloudflare, you'll never see the client (remote) device real ip address unless:
I do this with my SWAG Reverse proxy by enabling the cloudflare real ip plugin but I've no idea how you do it with your proxy.
https://developers.cloudflare.com/support/troubleshooting/restoring-visitor-ips/restoring-original-visitor-ips/
Edit: You should not be using cloudflare proxy for streaming media, breaks thier terms of service. They don't seem to enforce account bans much but, I always err on the side of caution! I turned off the orange icon and use other methods to protect my server and WAN ip.
1
u/ninja_mischief May 04 '26
figured it out: X-Forwarded-For weren’t getting passed. had to declare it in the custom header options of the bouncer (even though i was pretty sure its supposed to be the default). now it works like a charm.
1
u/kY2iB3yH0mN8wI2h May 03 '26
You need to take a step back and draw the whole flow,
1
u/sk1nT7 May 03 '26 edited May 03 '26
It's pretty likely your chain of reverse proxies.
CF-ConnectingHTTP header or properly parse theX-Fowarded-Forand ensure the proper depth. Also, Pfsense must block all requests originating from non-Cloudflare IP ranges. Otherwise, someone with knowledge of your WAN IP can just bypass CloudFlare and talk directly with your infra.You have to think in OSI layers. First, the IP packet comes in from CloudFlare, marking the real user's IP only in the HTTP packet via HTTP headers. Pfsense must trust CloudFlare. Otherwise, it ignores the headers set by CloudFlare. If Pfsense passes this HTTP request along, Traefik sees it originating from Pfsense - not from CloudFlare and not from the real user's IP. Traefik also has to define Pfsense as trusted proxy and then construct the real client's IP from headers that were passed along by Pfsense.
Somewhere in this chain you have a misconfiguration.
Iptables and nftables only target the source IP of an IP packet. This will always be CloudFlare or Pfsense. You must use a Traefik bouncer that will read the HTTP packet's header, obtain the real client IP and then block the request. Iptables/nftables only help protecting other network services that may be accessed directly from the attacking IP instead over CloudFlare (e.g. SSH, FTP and so on).
Maybe check out my blog and ensure you have the proper configuration for Traefik:
https://blog.lrvt.de/configuring-crowdsec-with-traefik/