Home  ›  Blog  ›  S4Hosting technical insights

• •

How to Stop Harmful Bots with Cloudflare Without Blocking Genuine Visitors

S4Hosting Cloudflare bot protection guide banner showing a shield, allowed search crawlers and real visitors, and blocked scraping bots and vulnerability scanners.

When a WordPress news website receives excessive automated requests, adding more VPS CPU is not always the answer. Cloudflare can reduce unwanted requests before they reach Nginx, PHP-FPM and MariaDB—provided the rules still let genuine readers, verified search crawlers, social preview bots and authorised publishing tools work.

In a recent S4Hosting troubleshooting case involving a high-traffic news portal on a Warsaw VPS, enabling Cloudflare Under Attack Mode was followed by a drop in one-minute load from roughly 3–5 to 0.59, with CPU idle rising above 80% in a subsequent snapshot. That is strong evidence that inbound HTTP request pressure mattered. It does not prove every challenged visitor was a malicious bot.

Quick takeaways

  • Block exploit probes and protect WordPress authentication endpoints.
  • Rate-limit demonstrably abusive crawling, rather than blocking all article visitors.
  • Preserve verified Google, Bing and Meta crawlers and legitimate news-app traffic.
  • Protect WordPress APIs and publishers with narrow, authenticated exceptions.
  • Replace emergency site-wide Under Attack Mode with targeted controls once origin traffic is stable.
S4Hosting chart of recommended Cloudflare actions for scrapers, vulnerability scanners, crawlers, readers and WordPress publishing automation
Recommended Cloudflare traffic-handling policy for high-traffic WordPress websites. Review each rule against your own application before enabling it.

Why Cloudflare Under Attack Mode reduced server load

Cloudflare’s emergency protection presents Managed Challenges to traffic that may otherwise reach the origin. Clients unable to pass the challenge often do not proceed to WordPress, saving PHP execution, database lookups and uncached-page processing. Cloudflare Security Events can show the actions taken, but a table of challenge events is not a complete origin traffic count.

In our diagnostic sample, Cloudflare encountered a mixture of headless-browser crawling, requests to obsolete category paths, attempts to probe sensitive configuration files, and traffic apparently associated with legitimate news-app readers and social previews. The operational lesson is to distinguish unwanted automation from useful automated services.

Step-by-step Cloudflare WAF and bot protection

1. Keep Under Attack Mode for emergencies, not as a permanent default

Open Cloudflare Dashboard → select the domain → Security and review the current security mode and Security Events. If request pressure is actively overwhelming the site, retaining Under Attack Mode temporarily may be justified. Before leaving it enabled indefinitely, check effects on readers, static files, search crawlers and REST API clients.

When targeted WAF and rate-limiting rules are ready and the site is stable, test disabling zone-wide Under Attack Mode while watching origin load and errors.

2. Block sensitive-file and vulnerability probes

Under Security → Security rules → Custom rules (labels may vary by dashboard version), create a narrowly scoped Block rule for confirmed exploit-probe paths. For example:

(http.request.uri.path contains "/.env" or
 http.request.uri.path contains "/.git/" or
 http.request.uri.path eq "/wp-config.php" or
 http.request.uri.path contains "/.aws/credentials")

This is an illustrative starting point, not a complete vulnerability signature. Keep Cloudflare Managed WAF rules enabled for common exploit techniques. Do not block all POST traffic or all traffic from a country simply because some scanners use it.

3. Rate-limit repeated WordPress login attempts

Create a separate rate-limiting rule for repeated POST requests to /wp-login.php. Start with a threshold appropriate to real login traffic and use Managed Challenge or Block after reviewing events. Enforce strong passwords and multi-factor authentication for privileged users.

If WordPress /xmlrpc.php is definitely unused, consider blocking it; if needed, protect it instead. Avoid blanket restrictions on /wp-admin/, /wp-json/ or /wp-admin/admin-ajax.php because valid admin, plugin and publishing workflows can depend on those paths.

4. Challenge aggressive page crawlers without penalising readers

Use Security → Security rules → Rate limiting rules to restrict unusually high-frequency HTML or archive requests. Measure the site’s normal traffic before selecting a threshold: a threshold such as 120 matching requests per minute per source IP may be a starting point for a trial, but it is not universally safe. Mobile carriers and offices may have many genuine readers behind one IP, and Cloudflare’s available rule options vary by plan.

Inspect repeated requests to old endpoints such as /en/Categories/, /te/Categories/ or obsolete .aspx paths. Confirm whether these routes should return a redirect before treating them as malicious. Do not rate-limit static image, CSS or JavaScript assets as though they were costly PHP pages.

5. Preserve verified Google, Bing, Meta and other useful crawlers

Cloudflare’s expression field cf.client.bot identifies recognised good bots. For broad custom bot-challenge rules, consider an exclusion such as not cf.client.bot so that verified crawlers can perform legitimate indexing and link preview retrieval.

Important: Excluding verified bots from your own challenge rule is different from bypassing all security protections. Avoid broad Skip all remaining custom rules policies that could also bypass sensitive-path protections. Do not trust a claimed Googlebot or Facebookbot user-agent by itself.

6. Keep WordPress publishing automation working

Automated news publishers, scheduled imports, webhooks and legitimate API clients can fail if the website-wide challenge is applied to machine-to-machine traffic. Do not globally exempt /wp-json/. Instead, where necessary, scope a Cloudflare exception to the exact API path and method plus a verified trusted source IP or stronger authentication. WordPress authentication and application-level permissions must remain in force.

A direct-database exporter may bypass Cloudflare completely, but a REST publishing fallback can still be challenged. Test both production and fallback paths after each rule change.

7. Avoid challenges on genuinely public static images

If Cloudflare events show repeated challenges on a public .webp favicon, JPG or PNG image, check whether it is a false positive. A narrowly scoped configuration exception for that specific asset can reduce disruption to mobile readers and link previews while keeping managed exploit protection active.

Do not automatically exempt dynamic image proxies or other scripts from WAF checks. They can be abused independently and should have validation, caching and request controls of their own.

8. Verify the changes and monitor the origin

After deploying targeted rules, test a logged-out article page, category navigation, static images, search and social previews, WordPress login, API authentication and scheduled publishing. Compare Cloudflare’s request outcomes with:

  • Origin requests, cache HIT/MISS and Nginx 403/429/5xx rates.
  • PHP-FPM worker utilisation and uncached WordPress response times.
  • MariaDB CPU, SELECT query rates and slow-query patterns.
  • VPS load averages, available memory and active swap-in/swap-out.

Keep a rollback plan. Once the origin remains stable with targeted controls, retire the temporary full-site Under Attack setting.

Cloudflare traffic policy: what to block and what to preserve

Traffic type Recommended response
Aggressive scrapers Rate-limit, challenge or block demonstrated abuse
Repeated high-frequency page crawling Rate-limit expensive paths based on observed traffic
Vulnerability scanners Block exploit probes; retain managed WAF
WordPress brute-force attempts Protect login and XML-RPC endpoints appropriately
Verified Google, Bing and Meta crawlers Preserve search indexing and social previews
Genuine news-app readers Allow normal browsing and static media requests
Authorised publishing automation Preserve narrowly authenticated API and import workflows

Frequently asked questions

Does Cloudflare Under Attack Mode block every bot?

No. It challenges eligible requests; some automated clients cannot complete the challenge and therefore do not reach the application. Cloudflare Security Events show actions such as Managed Challenge and Block, which should not be treated as identical.

Can Cloudflare bot protection hurt Google indexing or Facebook previews?

Yes, overly broad challenges or skip/block rules can affect legitimate automated services. Use verified-crawler identification, check actual security events, and test article previews and indexing paths rather than trusting a user-agent string.

Should we add more VPS CPU when bot traffic causes a load spike?

First determine whether expensive requests are legitimate and whether caching, WAF and rate limits can reduce unnecessary work. Upgrade capacity when normal traffic and the application workload genuinely require it—not merely to absorb avoidable abuse.

S4Hosting’s recommendation

Protect the origin without blocking the audience. Combine Cloudflare WAF and measured rate limiting with Nginx caching, tuned PHP-FPM concurrency, database query improvements and monitoring. The aim is lower server load and reliable access for readers, search crawlers and automated publishers.

For more infrastructure guidance, see our CWP security best-practices guide and explore S4Hosting’s hosting services.

Official Cloudflare documentation

Updated 1 November 2026. Cloudflare menus and available controls depend on plan and dashboard version. Review the policy for your environment before deployment.


Share this guide

Share this article with someone managing a website. Reactions appear just above this section.

Join the discussion 💬

Questions or feedback? Leave a comment below. Emojis are welcome 😊

One response to “How to Stop Harmful Bots with Cloudflare Without Blocking Genuine Visitors”

Leave a Reply

Your email address will not be published. Required fields are marked *