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.
- 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.
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
- 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.
- On Connect your domain, keep Search, Training and Agents on Allow.
- Read the rules that the zone has now. Change an existing rule; do not add a copy of it.
- 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.
Rule 1: allow your own server and good bots
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
- 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.
Rule 2: restrict the sign-in pages
Why: Bots guess passwords on the sign-in page. A person passes a managed challenge once; a script does not.
Action: Managed Challenge
- Challenge only the page (GET). A challenge on a background POST fails without a visible prompt.
Rule 2 for WordPress
Why: WordPress sign-in and remote sign-in endpoints.
Action: Managed Challenge
Rule 3: restrict old browsers
Why: Bot scripts keep the user agent of an old browser version. People update their browsers automatically.
Action: Managed Challenge
- 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.
Rule 4: HTTP/1.x and scanner probes (Laravel)
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
- 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.
Rule 4 for WordPress and WooCommerce
Why: The same HTTP/1.x check, with the WordPress machine paths left out.
Action: Managed Challenge
Rule 5: limit automated orders
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
- 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.
The rate limiting rule: pages for each address
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
- 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.