Skip to content

Protect your site from bots with Cloudflare's free plan

Five custom rules and one rate rule that stop spam orders, card testers, scanners and scrapers at Cloudflare's edge, while people, search engines and AI assistants still get in. Copy each rule with one click.

Olgun Özoktaş
Olgun Özoktaş Founder of FindUtils.com
6 min read
Protect your site from bots with Cloudflare's free plan BLOCKED INCOMING REQUESTS Spam & card testers Scanners & scrapers Human visitors Search engines AI assistants CLOUDFLARE EDGE FREE PLAN RULE 1 Allow server & good bots Verified search, AI search, own origin RULES 2–5 Challenge probes & bots Sign-in, old browsers, HTTP/1.x, spam RATE RULE Throttle scraper bursts 1 free rate limit rule per IP window Zero paid add-ons · CSR monitored LOCKED ORIGIN + ANALYTICS Origin IP hidden behind mTLS 443 allowlist: Cloudflare IPs only People Search + AI Clean live traffic signal CLEAN
Cloudflare's free edge quota stops noisy probes while passing people, search engines, and AI tools cleanly.
At a glance Security & Bots
  • Five custom WAF rules stop leak scanners, old-browser bots, HTTP/1.x scripts, and spam checkouts at the edge.
  • One free rate limiting rule throttles scrapers and card-testing bursts before they reach your origin.
  • Rule 1 runs first so verified search engines, AI assistants, and your own server skip downstream challenges.
  • Lock down origin ports 80/443 with Cloudflare IP ranges or Authenticated Origin Pulls so bots cannot bypass the edge.
olgunozoktas/cloudflare-bot-defense-skill Open-source agent skill with Laravel and WordPress variants, browser exceptions, and challenge auditing.
View repo

Bots fill a store with spam orders, test stolen cards on its checkout, scan it for leaked files and copy its pages. They also fill your analytics with visits that no person made. Cloudflare's free plan can stop most of them at its edge, before a request reaches your server.

This post gives you a tested rule set: five custom rules, one rate limiting rule, the AI bot settings and the origin lockdown. Each rule is below, with a button that copies it.

Where the rules come from

The rule set comes from Andrii Toniievych's article How to protect a WooCommerce store against bots and spam. Read it for the original reasons and screenshots.

We rewrote it as an open-source skill for AI coding agents: cloudflare-bot-defense-skill on GitHub (MIT license). The skill adds variants for Laravel and other stacks, exceptions for Samsung Internet and Firefox ESR, and the traps of the free plan. It also has a small script that shows which of your paths Cloudflare challenges.

Before you add a rule

  1. Add the domain to Cloudflare, and set each DNS record of the site to Proxied. A record that is "DNS only" sends visitors straight to your server, past every rule.
  2. On Connect your domain, keep Search, Training and Agents on Allow.
  3. Read the rules that the zone has now. Change an existing rule; do not add a copy of it.
  4. Find every path that a machine calls: webhooks, API clients, health checks, feeds. Each one goes into the "not" list of rule 4. In Laravel, the route list of your application shows them.

Warning: Cloudflare puts Googlebot, Bingbot and Applebot in the Training group. If you block Training, you lose search traffic.

Hide your server's address

A bot that knows your server's address skips Cloudflare and all its rules. The address leaks through old DNS records, a subdomain that is not proxied, and the headers of outgoing mail.

  • Allow web traffic (ports 80 and 443) on the server only from Cloudflare's address ranges.
  • Better: turn on zone-level Authenticated Origin Pulls so your server verifies Cloudflare's client certificate.
  • Never publish the server's address. The rules below use the placeholders <server IPv4> and <server IPv6>.

Warning: Turn on the certificate check on your server only after Cloudflare sends the certificate. In the wrong order, every request fails.

Check the result

After a day, open Security → Analytics and Security → Events. Look at the challenge solve rate (CSR) of each rule. A high rate means that people solve the challenge, so the rule catches too many people. Look at the sampled requests, and add each integration that a rule challenges to rule 1 or to the "not" list of rule 4.

Move the old-browser list of rule 3 forward every 2 or 3 months. Chrome and Firefox ship a new version about every 4 weeks.

The rules to copy

Open Security → Security rules → Create rule. Select Edit expression, paste the rule, and replace each value in angle brackets. Keep the order: rule 1 first.

Keep top-to-bottom order in Cloudflare

Step 1 of 8 Every stack

Rule 1: allow your own server and good bots

Skip remaining rules

Why: Your server may call its own site through Cloudflare. Good bots also skip the challenge rules, so a rule mistake never costs you search traffic.

Action: Skip (first): all remaining custom rules and all rate limiting rules

Cloudflare WAF expression
(cf.client.bot and cf.verified_bot_category in {"Search Engine Crawler" "Search Engine Optimization" "AI Search" "AI Assistant" "Page Preview" "Feed Fetcher" "Monitoring & Analytics"})or (ip.src in {<server IPv4> <server IPv6>})
Notes
  • Replace the two placeholders with the addresses of your own server.
  • Keep "Log matching requests" on, so you can see what the rule lets through.
Step 2 of 8 Laravel and other stacks

Rule 2: restrict the sign-in pages

Managed Challenge

Why: Bots guess passwords on the sign-in page. A person passes a managed challenge once; a script does not.

Action: Managed Challenge

Cloudflare WAF expression
http.request.method eq "GET"and http.request.uri.path in {"/login" "/register" "/forgot-password"}
Notes
  • Challenge only the page (GET). A challenge on a background POST fails without a visible prompt.
Step 3 of 8 WordPress

Rule 2 for WordPress

Managed Challenge

Why: WordPress sign-in and remote sign-in endpoints.

Action: Managed Challenge

Cloudflare WAF expression
(starts_with(http.request.uri.path, "/wp-login.php"))or (starts_with(http.request.uri.path, "/xmlrpc.php"))
Step 4 of 8 Every stack

Rule 3: restrict old browsers

Managed Challenge

Why: Bot scripts keep the user agent of an old browser version. People update their browsers automatically.

Action: Managed Challenge

Cloudflare WAF expression
not cf.client.botand not http.user_agent contains "Electron/"and not http.user_agent contains "ChatGPT"and not http.user_agent contains "Claude"and not http.user_agent contains "SamsungBrowser/"and (  http.user_agent contains "Chrome/11" or  http.user_agent contains "Chrome/12" or  http.user_agent contains "Chrome/13" or  http.user_agent contains "Chrome/141.0" or  http.user_agent contains "Chrome/142.0" or  http.user_agent contains "Chrome/143.0" or  http.user_agent contains "Android 9." or  http.user_agent contains "Android 8." or  http.user_agent contains "Android 7." or  http.user_agent contains "Android 6." or  http.user_agent contains "Android 5." or  http.user_agent contains "Firefox/11" or  http.user_agent contains "Firefox/12" or  http.user_agent contains "Firefox/13" or  (http.user_agent contains "Firefox/14" and not http.user_agent contains "Firefox/140."))
Notes
  • The version list is right for late November 2026. Move it forward every 2 or 3 months.
  • Electron apps, Samsung Internet and Firefox ESR 140 are left out on purpose.
Step 5 of 8 Laravel and other stacks

Rule 4: HTTP/1.x and scanner probes (Laravel)

Managed Challenge

Why: Browsers use HTTP/2 or HTTP/3. Most bot libraries use HTTP/1.1. The second half challenges scanners that look for WordPress files or a leaked .env.

Action: Managed Challenge

Cloudflare WAF expression
(not cf.client.bot and http.request.version in {"HTTP/1.0" "HTTP/1.1"} and http.host in {"<example.com>" "www.<example.com>"} and not starts_with(http.request.uri.path, "/cdn-cgi/") and not starts_with(http.request.uri.path, "/.well-known/") and not starts_with(http.request.uri.path, "/api/") and not starts_with(http.request.uri.path, "/stripe/") and not starts_with(http.request.uri.path, "/webhooks/") and not starts_with(http.request.uri.path, "/feed") and not starts_with(http.request.uri.path, "/sitemap") and not http.request.uri.path in {"/robots.txt" "/llms.txt" "/health" "/up" "/csp-report"} and not http.request.uri.path.extension in {"js" "css" "svg" "png" "jpg" "jpeg" "webp" "gif" "ico" "woff" "woff2" "webmanifest" "xml" "txt"})or (http.host in {"<example.com>" "www.<example.com>"} and (http.request.uri.path in {"/wp-login.php" "/xmlrpc.php"}  or starts_with(http.request.uri.path, "/wp-admin")  or starts_with(http.request.uri.path, "/wp-content")  or starts_with(http.request.uri.path, "/wp-includes")  or starts_with(http.request.uri.path, "/.env")  or starts_with(http.request.uri.path, "/.git/")))
Notes
  • Add every path that a machine calls (webhooks, API clients, health checks) to the "not" list.
  • A corporate proxy can send a person over HTTP/1.1. That person sees a challenge and passes it.
Step 6 of 8 WordPress

Rule 4 for WordPress and WooCommerce

Managed Challenge

Why: The same HTTP/1.x check, with the WordPress machine paths left out.

Action: Managed Challenge

Cloudflare WAF expression
(not cf.client.botand not starts_with(http.request.uri.path, "/wp-cron.php")and not starts_with(http.request.uri.path, "/wp-admin/admin-ajax.php")and not starts_with(http.request.uri.path, "/wp-content/")and not starts_with(http.request.uri.path, "/wp-includes/")and not starts_with(http.request.uri.path, "/wp-json/")and not starts_with(http.request.uri.path, "/checkout/order-received/")and not starts_with(http.request.uri.path, "/.well-known/")and not starts_with(http.request.uri.path, "/wc-api/")and not starts_with(http.request.uri.query, "wc-api=")and http.request.version in {"HTTP/1.0" "HTTP/1.1"})
Step 7 of 8 Stores

Rule 5: limit automated orders

Managed Challenge

Why: Card testers place many orders from many countries. Challenge the cart and the checkout for countries that you do not sell to.

Action: Managed Challenge

Cloudflare WAF expression
(starts_with(http.request.uri.path, "/checkout") and not ip.src.country in {"US" "CA"})or (starts_with(http.request.uri.path, "/cart") and not ip.src.country in {"US" "CA"})or (starts_with(http.request.uri.path, "/wp-json/wc/store/") and not ip.src.country in {"US" "CA"})
Notes
  • Replace the country codes and the paths with your own.
  • The WooCommerce Cart and Checkout blocks use /wp-json/wc/store/: with those blocks, remove the third line, or the checkout breaks.
Step 8 of 8 Content sites and apps

The rate limiting rule: pages for each address

Rate limit · Block

Why: The Free plan has one rate limiting rule. A scraper asks for many pages fast; a person does not.

Action: Block for 10 seconds; 40 requests in 10 seconds for each IP

Cloudflare WAF expression
(http.host eq "<example.com>" and not cf.client.bot and not starts_with(http.request.uri.path, "/js/") and not starts_with(http.request.uri.path, "/css/") and not starts_with(http.request.uri.path, "/images/"))
Notes
  • A store uses this slot for checkout attempts instead: POST to the checkout, 5 requests in 10 seconds.
  • Leave out every static folder, or one page load counts as many requests.
Olgun Özoktaş
Olgun Özoktaş · Founder of FindUtils.com

Building cookie-free software analytics for developers and founders. Practical notes on edge security, privacy, and fast dashboards.

Share on X

Start measuring your product without bot noise.

Explore the interactive live demo with no account, or join the waitlist to reserve your workspace.