You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Set up the [AppSec Component](/appsec/intro.md#introduction) to protect web applications running behind [HAProxy](https://www.haproxy.org/) using the **HAProxy SPOA remediation component**.
13
-
14
-
You will:
15
-
- Enable CrowdSec AppSec (WAF) in the Security Engine.
16
-
- Install and configure `crowdsec-haproxy-spoa-bouncer` so HAProxy can forward HTTP requests to AppSec.
17
-
- Validate everything by triggering a test detection.
8
+
Protect web applications running behind [HAProxy](https://www.haproxy.org/) with CrowdSec's [AppSec (WAF) Component](/appsec/intro.md#introduction), using the HAProxy SPOA remediation component to forward HTTP requests.
18
9
19
10
## Prerequisites
20
11
21
-
1. If you're new to the [AppSec Component](/appsec/intro.md#introduction) or **W**eb **A**pplication **F**irewalls, start with the [Introduction](/appsec/intro.md#introduction).
22
-
2. It's assumed that you have already installed:
23
-
-**CrowdSec [Security Engine](/intro.mdx)**: for installation, refer to the [QuickStart guide](/u/getting_started/installation/linux).
24
-
-**HAProxy**: already running and proxying your application(s).
If you already completed the [General Setup](general.mdx) (collections + acquisition), skip to [Remediation Component Setup](#remediation-component-setup).
29
-
:::
30
-
31
-
## AppSec Component Setup
12
+
Make sure the following are already done on the machine running HAProxy (each is a single-page install guide):
32
13
33
-
### Collection installation
14
+
1.**CrowdSec Security Engine** installed and running — see the [Linux quickstart](/u/getting_started/installation/linux).
15
+
2.**HAProxy** already running and proxying your application(s).
16
+
3.**HAProxy SPOA bouncer** (`crowdsec-haproxy-spoa-bouncer`) installed and registered against the CrowdSec LAPI — see the [SPOA bouncer guide](/u/bouncers/haproxy_spoa).
These <UnderlineTooltiptooltip="Collections are bundles of parsers, scenarios, and AppSec rules/configuration items.">collections</UnderlineTooltip> provide virtual patching (CVE rules), generic WAF detections, and the default AppSec configuration.
26
+
This pulls the [`appsec-virtual-patching`](https://app.crowdsec.net/hub/author/crowdsecurity/collections/appsec-virtual-patching) collection (rules for known CVEs, auto-updated daily) and the [`appsec-generic-rules`](https://app.crowdsec.net/hub/author/crowdsecurity/collections/appsec-generic-rules) collection (common attack patterns), plus the default AppSec configuration.
42
27
43
-
### Setup the acquisition
28
+
##2. Turn on the AppSec Component
44
29
45
-
Create `/etc/crowdsec/acquis.d/appsec.yaml` (see the [AppSec datasource](/log_processor/data_sources/appsec.md) for the full reference):
30
+
Create the acquisition file, then restart CrowdSec:
If AppSec runs on a different host (or in containers), update `appsec_url` to the correct reachable address.
97
72
:::
98
73
99
-
:::warning AppSec limitations with HAProxy SPOA (important)
100
-
HAProxy SPOA forwarding is constrained by HAProxy/SPOE/SPOA mechanics:
101
-
- Request bodies are only available if you enable buffering (`option http-buffer-request`) and they must fit within tight size limits (commonly capped at ~50KB in examples).
102
-
- 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**.
103
-
- You are not doing full “streaming” inspection: SPOA works with what HAProxy can capture and send to the agent within buffer/frame limits.
74
+
## 4. Verify
104
75
105
-
CrowdSec AppSec is still a single “source of truth” for rules/config: you can point multiple WAF-capable integrations to the same AppSec endpoint so rule updates stay in sync across your infrastructure.
106
-
107
-
Recommended layered approach:
108
-
- Use HAProxy SPOA for **edge enforcement** (IP/range/country decisions, ban/captcha) and lightweight WAF evaluation when the request fits within the configured limits.
109
-
- 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 of WAF-capable integrations include:
110
-
-[Nginx/OpenResty](nginxopenresty.mdx)
111
-
-[Traefik](traefik.mdx)
112
-
-[WordPress](wordpress.mdx)
113
-
:::
114
-
115
-
## Testing the AppSec Component + Remediation Component
116
-
117
-
:::note
118
-
Adjust the URL below to match your HAProxy frontend (HTTP/HTTPS, port, hostname).
119
-
:::
120
-
121
-
If you try to access `http(s)://<your-haproxy-url>/.env`, your request should be blocked:
76
+
Hit an endpoint that should trip an AppSec rule (adjust the URL to match your HAProxy frontend):
122
77
123
78
```bash
124
-
curl -i http://<your-haproxy-url>/.env
79
+
curl -I http://<your-haproxy-url>/.env
125
80
```
126
81
127
-

82
+
You should get an `HTTP/1.1 403 Forbidden` response.
128
83
129
-
You can also check AppSec metrics:
84
+
Check that CrowdSec recorded the block:
130
85
131
86
```bash
132
87
sudo cscli metrics show appsec
133
88
```
134
89
135
-
### Explanation
90
+
<details>
91
+
<summary>What just happened?</summary>
136
92
137
-
What happened in the test above is:
93
+
1.`curl` hit HAProxy at `/.env`.
94
+
2. HAProxy forwarded the request to the SPOA remediation component.
95
+
3. The bouncer queried the AppSec Component at `appsec_url`.
96
+
4. The request matched the [`vpatch-env-access`](https://app.crowdsec.net/hub/author/crowdsecurity/appsec-rules/vpatch-env-access) rule.
97
+
5. AppSec answered `403`; HAProxy blocked the request.
138
98
139
-
1. You requested `/.env` through HAProxy.
140
-
2. HAProxy forwarded the request to the SPOA remediation component (SPOE/SPOA).
141
-
3. The remediation component queried the AppSec Component at `appsec_url`.
142
-
4. The request matched the [AppSec rule to detect `.env` access](https://app.crowdsec.net/hub/author/crowdsecurity/appsec-rules/vpatch-env-access).
143
-
5. AppSec returned a blocking action (HTTP 403) to the remediation component.
144
-
6. HAProxy blocked the request.
99
+
</details>
145
100
146
-
## Next steps
101
+
## AppSec limitations with HAProxy SPOA
147
102
148
-
You are now running the AppSec Component on your CrowdSec Security Engine with HAProxy SPOA.
103
+
HAProxy SPOA forwarding is constrained by HAProxy/SPOE/SPOA mechanics:
104
+
- 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).
105
+
- 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**.
106
+
- This is not full streaming inspection: SPOA works with what HAProxy can capture within buffer/frame limits.
107
+
108
+
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.
109
+
110
+
Recommended layered approach:
111
+
- Use HAProxy SPOA for **edge enforcement** (IP/range/country decisions, ban/captcha) and lightweight WAF evaluation when the request fits within the configured limits.
112
+
- 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:
113
+
-[Nginx/OpenResty](nginxopenresty.mdx)
114
+
-[Traefik](traefik.mdx)
115
+
-[WordPress](wordpress.mdx)
116
+
117
+
## Next steps
149
118
150
-
As the next steps, you can:
151
-
- Monitor WAF alerts with `sudo cscli alerts list` and in the [CrowdSec Console](https://app.crowdsec.net).
152
-
- Review the [AppSec troubleshooting guide](/appsec/troubleshooting.md) and the [HAProxy SPOA remediation component docs](/u/bouncers/haproxy_spoa) if you need to investigate or refine the deployment.
119
+
- Monitor WAF alerts with `sudo cscli alerts list` or in the [CrowdSec Console](https://app.crowdsec.net).
120
+
- Review the [AppSec troubleshooting guide](/appsec/troubleshooting.md) and the [HAProxy SPOA bouncer docs](/u/bouncers/haproxy_spoa) if you need to investigate or refine the deployment.
153
121
- Explore [WAF deployment strategies](/appsec/advanced_deployments.mdx) if you want to expand beyond this initial setup.
0 commit comments