Dealing with Cloudflare Bot Protection for Mobile APIs
DNX |

When running an API behind Cloudflare, especially with Bot Fight Mode enabled, a common concern is whether legitimate mobile app traffic might get blocked.

After testing a real-world setup with a mobile app and API endpoint, here are the key findings and practical solutions.

Photo by Lisa Marie Theck on Unsplash

Mobile App Traffic vs Bot Fight Mode

Modern mobile apps (iOS and Android) typically use native networking stacks:

iOS β†’ CFNetwork (URLSession)

Android β†’ OkHttp

These clients:

use real TLS fingerprints

behave like real devices

send consistent, structured requests

Observation

Mobile app requests:

consistently returned 200 or 304

were not challenged

were not blocked

πŸ‘‰ In practice, Bot Fight Mode handled mobile traffic well.

But It’s Not a Guarantee

Bot Fight Mode is:

behavior-based and probabilistic β€” not deterministic

That means:

It works well under normal usage

But behavior can change over time

Potential risks

High-frequency or burst requests

Unusual query patterns

Changes in Cloudflare detection models

Traffic from less trusted networks

πŸ‘‰ So while it appears safe, there is still long-term risk of false positives.

The Core Tradeoff

You are balancing two things:

GoalApproach
Maximum protectionKeep Cloudflare proxy + Bot Fight Mode
Maximum reliabilityBypass Cloudflare filtering

Solution: Direct Access with DNS-only

To fully eliminate Bot Fight Mode interference, you can:

πŸ‘‰ Switch the API subdomain to DNS-only (no proxy)

This changes the flow:

Client β†’ Server (direct)

Instead of:

Client β†’ Cloudflare β†’ Server

TLS Requirement (Important)

When using DNS-only:

Cloudflare is no longer handling HTTPS

Your server must present a publicly trusted certificate

πŸ‘‰ Cloudflare Origin Certificates will NOT work

They are only valid when proxy is enabled.

Recommended Setup: Let’s Encrypt

Use a standard public certificate such as Let’s Encrypt:

trusted by browsers and mobile clients

works with direct connections

supports automation

Avoiding Downtime: Use DNS-01 Challenge

When issuing certificates, a common issue is:

HTTP validation fails when traffic is proxied

Instead of switching proxy on/off (which can cause downtime), use:

πŸ‘‰ DNS-01 challenge

This method:

validates ownership via DNS

does not depend on web server access

works with proxy ON or OFF

avoids any traffic disruption

Final Architecture

After setup:

API subdomain β†’ DNS-only

TLS β†’ Let’s Encrypt certificate

Mobile apps β†’ connect directly

Bot Fight Mode β†’ no longer in path

Key Takeaways

Bot Fight Mode generally works well with mobile apps

However, it is not guaranteed to remain stable

For critical API reliability, direct access is safer

πŸ‘‰ The most robust approach:

Use DNS-only for API

Use Let’s Encrypt for TLS

Use DNS-01 for zero-downtime certificate management

Final Thoughts

Bot protection systems are designed to strike a balance between security and usability.

In testing:

Mobile traffic behaved correctly

No immediate issues were observed

But because detection is adaptive:

It’s safe enough for now β€” but not something to rely on blindly.