On this pageWhere the WAF runs
A web application firewall reads each HTTP request and decides whether it looks like an attack. Whether you buy one as a service at a provider's edge or run one next to your application, the decisions come from rules, and most open-source WAF engines share one rule set: the OWASP Core Rule Set, or CRS. Knowing how CRS scores a request explains most of what any WAF does, including why it sometimes blocks your own users, and how to fix that without switching protection off.
Where the WAF runs
| Managed WAF service | Self-hosted WAF | |
|---|---|---|
| Where requests are filtered | At the provider's edge, before your server | On your server or a proxy you run |
| Who maintains the rules | The provider, with settings and exceptions for you | You, from CRS releases or a vendor's updates |
| Visibility | The provider's dashboard and log exports | Full logs, every rule match |
| TLS | The provider decrypts your traffic | Stays on machines you control |
| Main pitfall | Attackers who reach the origin directly skip the WAF | Tuning and updates are your job |
With a managed service, lock the origin down so only the provider's address ranges can reach it, or the WAF becomes optional for anyone who finds your server's address. Self-hosted engines that run CRS include ModSecurity, which moved from Trustwave to OWASP in 2024, and OWASP Coraza, written in Go and compatible with the same rule language, with connectors for Caddy, Envoy, HAProxy and NGINX. Packaged WAFs such as BunkerWeb build on these. SafeLine uses its own detection engine instead and is covered in the SafeLine setup guide.
How CRS scores a request
CRS detection rules do not block on their own. Each match adds points to the request's anomaly score according to its severity:
| Severity | Points |
|---|---|
| Critical | 5 |
| Error | 4 |
| Warning | 3 |
| Notice | 2 |
Once the request has been inspected, a blocking rule compares the total with the inbound threshold, 5 by default. At or above it, the request is refused with a 403. Responses get a similar check with a threshold of 4. One critical match, such as a SQL injection pattern, blocks on its own; two warnings, worth 6 together, do too. A request for /?file=/etc/passwd matches an OS file access rule at critical severity, scores 5 and is blocked.
The log tells the whole story. Each match carries a rule ID and a message, and the blocking rule, 949110, states the total that crossed the threshold. Those IDs are what you work with when tuning.
Paranoia levels
CRS groups its rules into four paranoia levels. The project describes them roughly like this:
- Level 1: baseline protection with few false positives. The default.
- Level 2: rules suited to sites handling real user data, such as names and addresses.
- Level 3: online-banking strength, with many false positives to tune away.
- Level 4: very strict rules for the most sensitive targets, which can take weeks to tune.
Each level includes the rules of the levels below it. You can also run a higher level for detection only: its extra rules log matches but never count toward blocking, so you see what level 2 would flag while level 1 still decides. In crs-setup.conf, uncomment and edit these rules:
SecAction "id:900000,phase:1,pass,t:none,nolog,setvar:tx.blocking_paranoia_level=1"
SecAction "id:900001,phase:1,pass,t:none,nolog,setvar:tx.detection_paranoia_level=2"
SecAction "id:900110,phase:1,pass,t:none,nolog,setvar:tx.inbound_anomaly_score_threshold=5,setvar:tx.outbound_anomaly_score_threshold=4"
Roll out without blocking your customers
A fresh rule set always flags some legitimate traffic: rich text editors, search boxes that accept code, JSON APIs with unusual fields. Plan for a tuning period instead of discovering it from support tickets.
- Start without blocking. Either set the engine to
SecRuleEngine DetectionOnly, which logs everything and blocks nothing, or follow the CRS project's suggestion: block from day one with a very high threshold, even 10,000, and lower it step by step. Higher-than-default thresholds let attacks through, so treat them as temporary. - Collect real traffic for a week or two, including the monthly jobs and admin tasks that do not run every day.
- Rank the rules that fired on legitimate requests, with the command below.
- Write exclusions for the genuine false positives, as narrowly as possible.
- Switch to blocking at the default threshold and keep reading the log for a while.
In ModSecurity's log format, each match carries its rule ID, so ranking them is one line. Adjust the path to wherever your engine writes its messages:
grep -o '\[id "[0-9]*"\]' /var/log/nginx/error.log | sort | uniq -c | sort -rn | head -20
Write exclusions narrowly
CRS's own guidance is clear on two points: never edit the rule files, because updates would overwrite your changes, and put each exclusion where it can work. Configure-time exclusions go after the CRS include, in RESPONSE-999-EXCLUSION-RULES-AFTER-CRS.conf:
# The 'comment' field may contain SQL-like text: skip it for rule 942100 only
SecRuleUpdateTargetById 942100 "!ARGS:comment"
Runtime exclusions go before the include, in REQUEST-900-EXCLUSION-RULES-BEFORE-CRS.conf, and can depend on the request:
# Remove rule 920230 only on the report export path
SecRule REQUEST_URI "@beginsWith /reports/export" \
"id:1100,phase:1,pass,t:none,nolog,ctl:ruleRemoveById=920230"
Choose the smallest change that solves the problem, in this order: one parameter for one rule on one path, then one parameter for one rule everywhere, then one rule on one path, and only then a rule everywhere. Removing a whole category, such as every SQL injection rule, is only reasonable where the backend runs no SQL at all. For well-known applications such as WordPress or Nextcloud, check the CRS plugin registry first: exclusion packages for popular software moved out of the core rules into plugins in CRS 4.
Test that it blocks
After every rule change or update, confirm on a site you operate that the WAF still blocks an obvious attack pattern and still serves normal pages:
curl -s -o /dev/null -w '%{http_code}\n' 'https://www.example.com/?file=/etc/passwd' # expect 403
curl -s -o /dev/null -w '%{http_code}\n' 'https://www.example.com/' # expect 200
Add a few requests that mimic your real users' heavier actions, such as saving a long article, to catch new false positives before your users do.
What a WAF does not do
A WAF filters known attack patterns in requests. It does not fix the vulnerable code behind them, though a targeted rule can buy time until a patch ships. It has little to say about broken access control, where a logged-in user asks for someone else's invoice with a perfectly normal request. It does not absorb floods either: on CloudSat, network-level DDoS filtering handles volumetric attacks before they reach the server, which leaves the WAF to judge the requests that do arrive.
FAQ
Should I use a managed WAF or run my own?
A managed service is quicker to adopt and filters before traffic reaches you, but it decrypts your traffic and needs the origin locked down. A self-hosted WAF keeps traffic and logs with you and costs tuning time. Many teams start managed for public sites and self-host where data must stay in their own systems.
Can I run CRS with nginx?
Yes, through ModSecurity with its nginx connector, through Coraza, or through a packaged WAF such as BunkerWeb that bundles both. Apache uses the ModSecurity module directly.
Will a WAF slow my site down?
Inspection adds some work to every request, more at higher paranoia levels and with large request bodies. Measure your own pages before and after, and set body inspection limits that match what your application accepts.
How often should I update the rules?
Follow CRS releases and update on the same schedule as the rest of your web stack, rerunning your block and allow tests after each update.
Run it on CloudSat. Cloud VPS on AMD EPYC and NVMe from $1.98/mo in 13 regions, delivered in under 5 minutes and paid in crypto. See plans or deploy a server.




