How do you keep bots off your website, and can Cloudflare help?
To keep bots off your website, start by knowing which bots you have
Before you keep bots off your website, decide which bots you actually want gone. Not every bot is a problem. Search engine crawlers, uptime monitors and AI search crawlers can all bring benefits. The bots worth stopping are those that scrape content, try to log in, submit spam through forms or hit the server hard enough to slow it down. Before blocking anything, look at your server logs to see which user agents and IP addresses are making requests, how often and to which pages.
Remember that a user agent can be faked. Google recommends verifying its crawlers by running a reverse DNS lookup on the IP address, checking that the hostname ends in googlebot.com, google.com or googleusercontent.com, and then running a forward DNS lookup to confirm it returns the same address. Google also publishes its crawler IP ranges as JSON files.
Layer one: robots.txt for polite bots
A robots.txt file tells crawlers which parts of a site they may request. Well behaved bots follow it. For example, to ask one crawler to stay away from the whole site:
``` User-agent: ExampleBot Disallow: / ```
The limitation is important. The Robots Exclusion Protocol, published as RFC 9309, states that its rules are not a form of access authorisation. Bots that ignore it, which includes most malicious ones, are not affected. Some user triggered AI fetchers, such as OpenAI's ChatGPT-User, also state that robots.txt rules may not apply to them, because a person asked for the page.
Layer two: block at the server or CDN
To actually stop a bot, the request has to be refused before it reaches your application. You can do this in your web server configuration by IP address or user agent, but bad bots change both often, so a CDN or web application firewall is usually more effective.
What Cloudflare offers
Cloudflare documents bot protection by plan:
- Free plan. Bot Fight Mode challenges traffic that matches known bot patterns across the whole domain. It cannot be bypassed with skip rules, so if it challenges something you need, you have to turn it off. WAF custom rules are available on all plans, with fewer rules than on higher plans, and simpler rate limiting rules with IP based counting can be created.
- Pro and Business plans. Super Bot Fight Mode adds allowing verified bots, choosing actions for each bot category, JavaScript detections and protection for static resources. Custom rules can create exceptions. Business and Enterprise plans add bot score distribution data and detailed bot analytics.
- AI crawler controls. Cloudflare's AI Crawler and Agent access policies let you choose actions for bots by behaviour, such as search, agent and training crawlers, with options to block, allow or disallow training through robots.txt. AI Crawl Control also shows which AI crawlers visit, how many requests they make and whether they break robots.txt rules.
Cloudflare warns that false positives are expected with its bot modes, particularly in the first few days, and recommends reviewing Security Events and adjusting rules.
Layer three: protect the targets
Bots usually aim at the same few places. Put rate limits on login, search and contact form endpoints, add a challenge such as Cloudflare Turnstile to forms, and make sure error pages are cheap for the server to produce. These steps reduce harm even from bots that get past the first two layers.
A practical order of work
- Review your logs and list the bots that visit.
- Verify important search crawlers before you trust or block them.
- Use robots.txt to set out which crawlers are welcome.
- Turn on bot protection at your CDN, starting with the least aggressive settings.
- Add rate limits and form challenges.
- Check Security Events and your logs after each change, and allow anything blocked by mistake.
See which bots are visiting
Our Real Traffic Audit reads the access log you download from your host, entirely in your browser, and sorts each request into your own server, AI crawlers, search engines, headless browsers, other bots and you, then grades what is left as likely or confirmed people. That shows which bots are visiting before you decide what to allow or block.
Sources
- Useful robots.txt rules
- RFC 9309: Robots Exclusion Protocol
- Verify requests from Google crawlers and fetchers
- Overview of OpenAI crawlers
- Stop malicious bots while allowing legitimate traffic (Cloudflare)
- AI Crawler and Agent access policies (Cloudflare)
- Manage AI crawlers (Cloudflare AI Crawl Control)
Frequently asked questions
Will it hurt my SEO to keep bots off your website?
It can if you block the wrong ones. Search engines such as Googlebot need access to crawl and index your pages, and AI search crawlers such as OAI-SearchBot and PerplexityBot need access for your pages to appear in their answers. Verify a bot before blocking it, allow verified search crawlers, and test changes, because Cloudflare notes that its bot modes can produce false positives.
Why do fake bots claim to be Googlebot?
A user agent is just a text label that any program can send, so scrapers often copy Googlebot's to avoid being blocked. Google recommends checking the requesting IP address with a reverse DNS lookup, confirming it belongs to googlebot.com, google.com or googleusercontent.com, then running a forward lookup to confirm it matches. Google also publishes its crawler IP ranges.