haproxy spoa bouncer
HI all, I am trying to use haproxy spoa bouncer but the issue I am seeing is that my webiste is behind cloudflare, I've managed to pass the real IPs to both haproxy logs and down the line to nginx but the bouncer is still only seeing cloudflare's IPs. I've tried a few things using ai unfortunately nothing really helped
My crowdsec.cfg:
My haproxy.cfg frontend: ```frontend web_traffic_in
mode http
bind 10...:443 ssl crt /etc/ssl/ alpn h2,http/1.1
# ACL to identify Cloudflare traffic (needs to be tcp-request compatible)
acl from_cf src -f /etc/haproxy/CF_ips.list
# FIRST: Replace source IP with real client IP http-request set-src req.hdr(CF-Connecting-IP) if from_cf
# Also set the header for other components http-request set-header CF-Connecting-IP %[var(sess.real_ip)] # Set source for logging http-request set-src var(sess.real_ip) # CrowdSec SPOE filter filter spoe engine crowdsec config /etc/haproxy/crowdsec.cfg http-request set-header X-CrowdSec-Remediation %[var(txn.crowdsec.remediation)] http-request lua.crowdsec_handle if { var(txn.crowdsec.remediation) -m found } # Add headers option forwardfor http-request add-header X-Forwarded-Proto https if { ssl_fc } # ACLs for routing acl ** hdr(host) -i **
# Use ACLs to route requests use_backend
# FIRST: Replace source IP with real client IP http-request set-src req.hdr(CF-Connecting-IP) if from_cf
# Also set the header for other components http-request set-header CF-Connecting-IP %[var(sess.real_ip)] # Set source for logging http-request set-src var(sess.real_ip) # CrowdSec SPOE filter filter spoe engine crowdsec config /etc/haproxy/crowdsec.cfg http-request set-header X-CrowdSec-Remediation %[var(txn.crowdsec.remediation)] http-request lua.crowdsec_handle if { var(txn.crowdsec.remediation) -m found } # Add headers option forwardfor http-request add-header X-Forwarded-Proto https if { ssl_fc } # ACLs for routing acl ** hdr(host) -i **
# Use ACLs to route requests use_backend
17 Replies
Important Information
This post has been marked as resolved. If this is a mistake please press the red button below or type
/unresolve© Created By WhyAydan for CrowdSec ❤️
Yes, we figured having an upstream proxy will cause issue especially since our "out of box" uses on-tcp-request which wont happen at the right layer.
So I guess even passing:
wont work?
and thinking now it might not parse to the correct type
@iiamloz your original response before edited ended up returning this: the edited reponse crashes haproxy on restart :
ahh okay, didnt know if the ACL you defined was global or not
you can remove the if case
the "working" logs dont seem to show what ip it is checking?
WIth the crowdsec.cfg I provided the logs show this

if I try your suggestion without the if case it doesn't return any IP logs yes
😕
Just to confirm that I checked again:

Okay @Spratt try
It works
but you may want to move or reuse the acl adding a
to prevent spoofing if not firewalled
good Idea. Thanks a lot for helping
Resolving haproxy spoa bouncer
This has now been resolved. If you think this is a mistake please run
/unresolveGitHub
Add example configuration for HAProxy behind upstream proxy by Laur...
fix: #13
This adds example configurations demonstrating how to extract real client IP when HAProxy is deployed behind an upstream proxy (nginx, Cloudflare, etc.).
Key changes:
docker-compose.proxy...
however, I still see issues @Spratt
we may have to split it to two message
crowdsec-tcp and crowdsec-http
and need to do the ip check in crowdsec-httpI see how that could be an issue
going to create a pr now, that means you can drop the
crowdsec-ip message and just do crowdsec-http as long as you pass the src-ip variable it will do the check.
Okay created a seperate PR and update the examples to be based on the new code once merged 😅