CrowdSec WAF QuickStart for HAProxy (SPOA)
Protect web applications running behind HAProxy with CrowdSec's AppSec (WAF) Component, using the HAProxy SPOA remediation component to forward HTTP requests.
Prerequisites
Make sure the following are already done on the machine running HAProxy (each is a single-page install guide):
- CrowdSec Security Engine installed and running — see the Linux quickstart.
- HAProxy already running and proxying your application(s).
- HAProxy SPOA bouncer (
crowdsec-haproxy-spoa-bouncer) installed and registered against the CrowdSec LAPI — see the SPOA bouncer guide.
1. Install the AppSec rule collections
sudo cscli collections install \
crowdsecurity/appsec-virtual-patching \
crowdsecurity/appsec-generic-rules
This pulls the appsec-virtual-patching collection (rules for known CVEs, auto-updated daily) and the appsec-generic-rules collection (common attack patterns), plus the default AppSec configuration.
2. Turn on the AppSec Component
Create the acquisition file, then restart CrowdSec:
sudo mkdir -p /etc/crowdsec/acquis.d
sudo tee /etc/crowdsec/acquis.d/appsec.yaml > /dev/null <<'EOF'
appsec_configs:
- crowdsecurity/appsec-default
labels:
type: appsec
listen_addr: 127.0.0.1:7422
source: appsec
EOF
sudo systemctl restart crowdsec
3. Enable AppSec forwarding in the SPOA bouncer
Edit /etc/crowdsec/bouncers/crowdsec-spoa-bouncer.yaml and add the appsec_url plus the appsec block under your host(s):
# AppSec (WAF forwarding)
appsec_url: "http://127.0.0.1:7422"
appsec_timeout: "200ms"
hosts:
- host: "*"
appsec:
always_send: false
Restart the bouncer:
sudo systemctl restart crowdsec-spoa-bouncer
4. Verify
Hit an endpoint that should trip an AppSec rule (adjust the URL to match your HAProxy frontend):
curl -I http://<your-haproxy-url>/.env
You should get an HTTP/1.1 403 Forbidden response.
Check that CrowdSec recorded the block:
sudo cscli metrics show appsec
What just happened?
curlhit HAProxy at/.env.- HAProxy forwarded the request to the SPOA remediation component.
- The bouncer queried the AppSec Component at
appsec_url. - The request matched the
vpatch-env-accessrule. - AppSec answered
403; HAProxy blocked the request.
AppSec limitations with HAProxy SPOA
HAProxy SPOA forwarding is constrained by HAProxy/SPOE/SPOA mechanics:
- Request bodies are only available if you enable buffering (
option http-buffer-request) and must fit within tight size limits (commonly capped at ~50 KB). - When the body is too large (uploads, large JSON, etc.), you typically fall back to a "no-body" SPOE group, which means body-dependent WAF rules cannot match.
- This is not full streaming inspection: SPOA works with what HAProxy can capture within buffer/frame limits.
CrowdSec AppSec is a single source of truth for rules — you can point multiple WAF-capable integrations at the same AppSec endpoint so rule updates stay in sync.
Recommended layered approach:
- Use HAProxy SPOA for edge enforcement (IP/range/country decisions, ban/captcha) and lightweight WAF evaluation when the request fits within the configured limits.
- Put a full-featured L7 proxy/WAF-capable integration downstream (or protect the app directly) when you need deeper inspection of large bodies, file uploads, or application-specific request parsing. Examples:
Next steps
- Monitor WAF alerts with
sudo cscli alerts listor in the CrowdSec Console. - Review the AppSec troubleshooting guide and the HAProxy SPOA bouncer docs if you need to investigate or refine the deployment.
- Explore WAF deployment strategies if you want to expand beyond this initial setup.