Skip to content
Shahid Malla

WHMCS Behind Cloudflare: Real Visitor IPs, Cache and Bot Rules

What to change on both sides when WHMCS sits behind Cloudflare: Trusted Proxies for real visitor IPs, cache bypass on the cart and admin, a WAF rule on the admin path, and the captcha types WHMCS supports.

· Published · 12 min read · 7 steps
WHMCS Behind Cloudflare: Real Visitor IPs, Cache and Bot Rules

Putting WHMCS behind Cloudflare takes four settings, not one. Add Cloudflare's IP ranges to Trusted Proxies on the Security tab so logins and orders record the real visitor IP, bypass the cache on the cart, client area and admin paths, add a firewall rule on the admin path, and turn off Rocket Loader and script minification for the WHMCS domain.

Running WHMCS behind Cloudflare means the DNS records for the billing domain are proxied, so every browser request reaches Cloudflare first and Cloudflare forwards it to your server. Your server then sees a Cloudflare address instead of the visitor's, and Cloudflare decides what to cache, challenge or block before WHMCS runs.

Everything below is checked against the WHMCS 9.1 and Cloudflare documentation, read on 30 November 2026. The WHMCS documentation home page listed 9.1 as General Availability that day; the menu paths are the same on 9.0 and 8.13.

Five-step order for putting WHMCS behind Cloudflare: proxy the DNS record, restore real IPs, bypass cache, add an admin firewall rule, then set the captcha
The order I work in, because each step depends on the one before it. Source: shahidmalla.com.

In words: proxy the hostname, restore the real visitor IP, keep the cache off authenticated pages, put a rule on the admin path, then set the captcha.

How do you proxy the WHMCS hostname safely?

Turn the orange cloud on only after the origin can answer HTTPS on its own, then switch off the two Cloudflare features WHMCS names as incompatible.

In the Cloudflare DNS tab a record is either Proxied, the orange cloud icon, or DNS only, which answers with your server's own address. Once proxied, every request reaches your server from Cloudflare IP ranges, so allow those at the origin firewall and block everything else on ports 80 and 443. Otherwise anyone who finds your origin address walks around the proxy.

Two Cloudflare optimizations have to go. The Security tab documentation states it plainly: some Cloudflare features are not compatible with WHMCS, and Script Minimisation and Rocket Loader must be disabled for the WHMCS installation domain. On a subdomain of a marketing site, scope a configuration rule to the WHMCS hostname instead of the whole zone.

The encryption mode bites too. Flexible sends traffic to the origin over plain HTTP, so it loops against an HTTPS redirect at the server; my guide to forcing HTTPS in WHMCS has the detail.

A short checklist before the orange cloud goes on:

  • The origin answers HTTPS on its own IP with a certificate that is not expired.
  • The encryption mode is Full (strict), not Flexible.
  • Rocket Loader and script minification are off for the WHMCS hostname.
  • Cloudflare's ranges are allowed at the server firewall.
  • You know the current admin directory name, and have a way back in if a rule goes wrong.

How do you get the real visitor IP into WHMCS?

Add Cloudflare's published ranges under Trusted Proxies on the Security tab at Configuration > System Settings > General Settings, and leave Proxy IP Header blank unless your proxy uses something other than X_FORWARDED_FOR.

The Security tab documentation names Cloudflare among the services that need Trusted Proxies, and says what skipping it costs: logins and orders look as if they come from the proxy, and the real location is masked for logging, access authorization and fraud detection.

WHMCS can do this for you. Its Cloudflare Proxy Check Errors page describes a System Health warning, "WHMCS is running behind a CloudFlare proxy, but you have not configured trusted proxy settings", with a link that adds Cloudflare's addresses for you. Check System Health before editing by hand.

When the list is wrong, WHMCS falls back through PHP variables in the order on the Server IP Address in Logs page, taking the first with a usable, non-local address.

OrderVariable WHMCS checks
1HTTP_CLIENT_IP
2HTTP_X_FORWARDED_FOR
3HTTP_X_FORWARDED
4HTTP_X_CLUSTER_CLIENT_IP
5HTTP_FORWARDED_FOR
6HTTP_FORWARDED
FallbackREMOTE_ADDR

Fix the web server too. Cloudflare's HTTP headers reference recommends reading CF-Connecting-IP rather than X-Forwarded-For, because it holds exactly one address. The guide to restoring original visitor IPs gives the server side: mod_remoteip with RemoteIPHeader CF-Connecting-IP on Apache, ngx_http_realip_module with real_ip_header CF-Connecting-IP on nginx, and a warning that mod_cloudflare is no longer supported.

This is not cosmetic. The Security tab documentation says WHMCS blocks an address that tries the Admin Area with a valid username and the wrong password three or more times, for 15 minutes by default. On an install that sees only Cloudflare addresses that ban lands on the shared proxy address, so one stranger's guessing locks out your own staff. My guides on fraud prevention and firewall hardening cover both sides.

Which WHMCS pages must Cloudflare never cache?

The cart, the client area, the admin area and anything that sets a cookie. In a stock configuration Cloudflare already leaves them alone, and the damage comes from a rule somebody adds later.

Cloudflare's default cache behavior page is clear: the CDN caches by file extension and does not cache HTML or JSON. It also skips caching when the response sets Set-Cookie, when Cache-Control is private, no-store, no-cache or max-age=0, and when the method is not GET. A logged-in WHMCS page fails several of those at once.

The failure I get called about is a cache-everything rule written for a marketing site that shares the zone. That rule can serve an invoice page to the next visitor, so write the bypass rule first and keep it above it.

PathWhat to doWhy
/cart.phpBypass cacheOrder state and prices are per session
/clientarea.php, /viewinvoice.php, /dl.phpBypass cacheAuthenticated pages and customer documents
Your admin directoryBypass cacheStaff pages, and the firewall rule goes here too
/templates/, /assets/Leave to the defaultAlready cached by file extension

Cache Rules is the current place to do this: one expression with a Bypass cache action. The settings reference lists the builder's fields, including URI Path (http.request.uri.path), Cookie and Hostname, with operators for equals, contains, starts with and matches regex. The Rules language reference puts the matches operator on Business and Enterprise plans only, so on Free and Pro use equals and contains:

(http.request.uri.path eq "/cart.php")
or (http.request.uri.path eq "/clientarea.php")
or (http.request.uri.path contains "/admin/")

That page also notes a bypassed response may report DYNAMIC rather than an explicit bypass, so DYNAMIC is not a broken rule.

How do you lock the WHMCS admin path at the edge?

With one WAF custom rule that matches the admin directory and challenges or blocks anything that is not a staff address, so a stranger never reaches the login form.

Start by renaming the directory. Step five of the WHMCS Enhancing Security page is to rename the admin directory, because a custom name makes the login URL harder for bots to find. Your edge rule matches that name, so it breaks if you rename it again.

Cloudflare's custom rules are on every plan, with an expression and an action such as Block, Managed Challenge or Skip. The page on creating a custom rule gives the sequence I follow every time: the Log action is Enterprise only, so on other plans start with Managed Challenge, review what it matched in Security Events, then switch to Block.

The rule matches the directory and exempts your own addresses, with the action on Managed Challenge while you watch it:

(http.request.uri.path contains "/your-admin-dir/"
 and not ip.src in {203.0.113.4 198.51.100.7})

Rule limits are per zone and per plan:

Per zoneFreeProBusinessEnterprise
Cache rules102550300
WAF custom rules5201001,000
Regex in expressionsNoNoYesYes

Those counts come from the Cache Rules and custom rules availability tables, and the regex row from the Rules language operators page, read on 30 November 2026. Five rules covers an admin rule, a callback rule and a country rule, so keep expressions broad. Keep the WHMCS controls too: Failed Admin Login Ban Time and Whitelisted IPs guard against different mistakes than an edge rule does.

Which captcha does WHMCS support behind Cloudflare?

Its own six-character image captcha, two reCAPTCHA v2 options, reCAPTCHA v3, and hCaptcha in two forms. Cloudflare Turnstile is not on that list, so a "Cloudflare captcha" on a WHMCS form means either a Cloudflare challenge in front of the page or custom code.

Captcha TypeMethodWhat it needs
Default (6 Character Verification Code)Verification codeGD2 on the server, no keys
reCAPTCHA v2CheckboxGoogle site key and secret key
Invisible reCAPTCHA v2InvisibleGoogle site key and secret key
reCAPTCHA v3InvisibleKeys plus a score threshold, default 0.5
hCaptchaCheckboxhCaptcha keys plus a score threshold
Invisible hCaptchaInvisiblehCaptcha keys plus a score threshold

WHMCS recommends reCAPTCHA v3 or hCaptcha for their protection against automated captcha solvers. The two scoring systems are inverted: hCaptcha runs 1 for least restrictive and 0 for most, the opposite way round from reCAPTCHA v3. Copying a threshold from one to the other quietly turns protection off.

Enabling a captcha is two settings. Captcha Form Protection chooses Always Enabled, Enabled for Unauthenticated Visitors Only or Never Enabled. Captcha for Selected Forms is where you tick where it appears: Shopping Cart Checkout, Domain Checker, Client Registration, Contact Form, Ticket Submission and Login Forms. The half-done setup I find most often is a captcha enabled with the checkout box unticked.

Cloudflare's vocabulary has moved on. Its challenges documentation states that Cloudflare does not use CAPTCHA puzzles or visual tests and that most visitors pass automatically, so a Managed Challenge checks the browser rather than asking your customer to solve anything. Turnstile embeds on any site, but WHMCS has no built-in option for it.

How do you sell Cloudflare DNS to your own clients?

Two businesses hide behind that question: reselling Cloudflare plans, and running your customers' zones in your own account and billing through WHMCS. The second is the one most hosts can start this week.

Know the zone setups before you price anything. Cloudflare's DNS setups page says that on Free and Pro the primary (full) setup is the only one available; CNAME setup, which lets a customer keep their DNS provider and proxy only chosen hostnames, needs Business or Enterprise. The same page shows how to put zones into DNS-only mode through the API, which is how you sell plain DNS without proxying.

Bar chart of Cloudflare plan list prices: Free at zero, Pro at 25 dollars monthly or 20 annually, Business at 250 monthly or 200 annually
Cloudflare plan list prices, read on 30 November 2026. Source: cloudflare.com/plans.
PlanBilled monthlyBilled annually
Free$0$0
Pro$25 per month$20 per month
Business$250 per month$200 per month
ContractCustomBilled annually

Those list prices come from the Cloudflare pricing page, read on 30 November 2026. They are why most hosts sell managed DNS on free zones in their own account rather than reselling Pro.

The mechanics inside WHMCS are ordinary provisioning work. A scoped API token creates the zone when the service is set up, writes the records from a template, and shows some in the client area. Keep the token out of template files and put the nameserver change behind a confirmation, because that is the step that can take a customer's site down. I package that work as a module, Cloudflare DNS automation for WHMCS, which is my own product, so read it as an option and not a recommendation. My web hosting expert page covers how I scope a DNS and hosting line.

When is Cloudflare the wrong answer for WHMCS?

When the hostname is not serving browsers, or when nobody owns the configuration after you leave. The proxy adds a second place where requests can be stopped, and a billing system is full of requests that must never be stopped.

Decision flow asking whether a hostname serves WHMCS pages, answers HTTPS on its own certificate, has Rocket Loader off and allows Cloudflare ranges at the origin firewall
How I decide whether a given WHMCS hostname should be proxied. Source: shahidmalla.com, from my own setup routine.

In words: a hostname that does not serve the WHMCS web pages stays DNS only. If it does, the origin needs its own working certificate, Rocket Loader and script minification off for that hostname, and the firewall set to allow Cloudflare's ranges. Trusted Proxies and the cache bypass rule come after the orange cloud is on, because a cache rule only matches on a proxied record.

  • Payment and API callbacks. Cloudflare's bot solutions page describes Bot Fight Mode on Free and Super Bot Fight Mode on the paid plans as toggles that challenge detected bots across your entire domain, with no way to write rules on bot score or target one endpoint. Only Super Bot Fight Mode supports WAF custom rule exceptions, so use a custom rule with a Skip action on the callback path.
  • Upload limits. The default cache behavior page gives the maximum upload size as 100 MB on Free and Pro and 200 MB on Business, so a large import file or attachment can fail for that reason alone.
  • Pseudo IPv4. Set to Overwrite Headers it replaces CF-Connecting-IP and X-Forwarded-For with a pseudo IPv4 address, keeping the real IPv6 address only in CF-Connecting-IPv6, so WHMCS logs an address the visitor never used.

One honest limit: Cloudflare protects the path to your server, and does nothing about an out-of-date WHMCS or a module with a hole in it.

What else do people ask about WHMCS and Cloudflare?

Why do all WHMCS logins and orders show the same IP address?

Because the proxy's address is reaching WHMCS instead of the visitor's. Open Configuration > System Health and look for the Cloudflare Proxy Check warning, which offers a link that adds Cloudflare's ranges to Trusted Proxies for you. If it is not there, set Trusted Proxies by hand on the Security tab.

Can I use Cloudflare Turnstile as the WHMCS captcha?

Not through the built-in setting. The Captcha Type list offers only the default image captcha, the two reCAPTCHA options and the two hCaptcha options. Turnstile can be added with custom development, but it is not a setting you switch on.

Does Cloudflare break WHMCS payment callbacks?

Not on its own. A gateway callback is a POST, which Cloudflare never caches, and an ordinary proxied zone passes it through. Callbacks break when a bot toggle or a country rule challenges the gateway, so allow the callback path with a Skip action and read Security Events after any new rule.

Do I need a paid Cloudflare plan for this?

No. Cache Rules and WAF custom rules are on every plan including Free, with lower limits and no regex in expressions. A paid plan buys more rules, regex matching, CNAME setup and Super Bot Fight Mode, none of which a single billing hostname needs.

If your install is behind Cloudflare and the symptoms match none of this, I audit that kind of configuration under WHMCS support and maintenance, with a free scoping call of about 30 minutes and a written quote within one business day.

Last reviewed 30 November 2026. Disclosure: I sell WHMCS and web development work, including a Cloudflare DNS module, so I am not neutral. I am CTO at ElySpace, a freelance developer for Marmaids LLC, and founder of WHMCSPilot and MagizAI.

Share this article

Shahid Malla

Written by

Shahid Malla

Freelance WHMCS developer and web designer with 13+ years of client work. CTO at ElySpace, freelance developer for Marmaids LLC, and founder of WHMCSPilot and MagizAI.

Got a project like this?

Tell me what you need and I will send a written quote within one business day.