Putting your website behind Cloudflare feels like flipping a security switch — DDoS protection, a WAF, and a hidden IP, all at once. But there is a catch most site owners never check: if attackers can discover your origin server's real IP address, they can bypass Cloudflare entirely and hit your server directly. This guide explains exactly how origin IPs leak, how to verify whether yours is exposed, and the concrete steps to lock your origin down so Cloudflare actually protects it.
Why Hiding Your Origin IP Matters
When you proxy your domain through Cloudflare (the orange cloud in your DNS settings), visitors connect to Cloudflare's edge network instead of your server. Cloudflare filters malicious traffic, then forwards legitimate requests to your origin. The protection only works as long as one assumption holds: attackers do not know your origin's real IP address.
If that IP leaks, an attacker can send traffic straight to your server, skipping Cloudflare's WAF and DDoS mitigation. Your “protected” site is then exactly as exposed as it was before you signed up. This is one of the most common — and most overlooked — misconfigurations in shared hosting and VPS setups.
How Attackers Find Your Origin IP
According to Cloudflare's own documentation and security research from Detectify, there are several well-known ways an origin IP gets discovered. Understanding them is the first step to closing the gaps.
1. Historical DNS records
DNS records are public by nature. Even after you enable the Cloudflare proxy, services that archive DNS history may still hold the old A record that pointed directly to your server before Cloudflare was added. An attacker simply looks up your domain's DNS history and reads the original IP.
2. SSL certificate scanning
Services continuously scan the entire internet on port 443 and log which IP serves a certificate for which domain. If your origin server still presents a certificate for your domain directly, a certificate search engine can reveal the IP hosting it — completely bypassing DNS.
3. Unproxied (DNS-only) records
This is the most common leak. Records like ftp.yourdomain.com, cpanel.yourdomain.com, mail.yourdomain.com, or a leftover direct.yourdomain.com are often left as DNS-only (grey cloud) because they cannot be proxied. Each one publicly resolves to your origin IP.
4. Email headers
Cloudflare does not proxy email. When your server sends an email — a password reset, an order confirmation, or a bounce message to a non-existent address — the message headers frequently contain the sending server's real IP. An attacker only has to trigger one email and read the headers.
5. Subdomain enumeration
Attackers brute-force common subdomain names looking for one that was never proxied. Development, staging, and admin subdomains are frequent offenders because they are set up quickly and forgotten.
How to Check If Your Origin IP Is Exposed
Before fixing anything, find out what is currently leaking. Work through this audit:
- Review every DNS record. In your Cloudflare dashboard, open DNS → Records. Look at every
AandAAAArecord. Any record showing a grey cloud (DNS-only) is publicly exposing whatever IP it points to. - Check your mail records.
MXrecords and theArecord they point to (oftenmail.) usually expose the IP. If your mail server runs on the same machine as your website, that IP is your origin. - Search certificate transparency logs. Look up your domain on a certificate search service and note any IP serving a certificate for your domain outside of Cloudflare.
- Test direct access. If you know your server IP, try opening
https://YOUR_ORIGIN_IP/in a browser. If your website loads, your origin is accepting connections from anyone — not just Cloudflare.
The Fix: Allow Only Cloudflare to Reach Your Origin
Hiding the IP is helpful, but the real guarantee is to configure your origin so it only accepts connections from Cloudflare. Even if an attacker discovers your IP, the server simply refuses their traffic. Cloudflare's official guidance recommends exactly this approach.
Option A: Firewall allowlist (VPS / root access)
If you manage your own server, configure the firewall to deny all inbound web traffic except from Cloudflare's published IP ranges. Cloudflare maintains the current list at cloudflare.com/ips. With ufw on Ubuntu, the pattern looks like this:
# Default: deny incoming web traffic
sudo ufw default deny incoming
# Allow HTTP/HTTPS ONLY from Cloudflare ranges
# (repeat for every range listed at cloudflare.com/ips)
for ip in $(curl -s https://www.cloudflare.com/ips-v4); do
sudo ufw allow from $ip to any port 443 proto tcp
sudo ufw allow from $ip to any port 80 proto tcp
done
# Keep your own SSH access on a separate rule
sudo ufw allow from YOUR_ADMIN_IP to any port 22 proto tcp
sudo ufw enableAfter this, any request to ports 80/443 that does not originate from Cloudflare is dropped. Remember to re-check the IP list periodically — Cloudflare does update it.
Option B: Authenticated Origin Pulls (mTLS)
For a cryptographic guarantee rather than an IP-based one, enable Authenticated Origin Pulls. This makes Cloudflare present a client certificate when it connects to your origin, and your server rejects any connection that does not present that certificate. Even traffic from a spoofed Cloudflare IP fails. You enable it under SSL/TLS → Origin Server → Authenticated Origin Pulls in Cloudflare, then configure your web server to require the Cloudflare origin certificate.
Option C: Shared hosting (cPanel without root)
On shared hosting you usually cannot edit the server firewall, but you still have options:
- Use an
.htaccessrule to reject requests that did not pass through Cloudflare, by checking for theCF-Connecting-IPheader and allowlisting Cloudflare ranges withmod_remoteipwhere available. - Ask your hosting provider whether they support allowlisting Cloudflare IPs at the server firewall — many cPanel hosts can apply this for you on request.
- Set Cloudflare SSL mode to Full (Strict) so the connection between Cloudflare and your origin is encrypted and certificate-validated end to end.
Plugging the Common Leaks
Locking the firewall handles direct attacks, but you should still close the information leaks so your IP is not trivially discoverable:
- Proxy everything you can. Switch grey-cloud records to orange where possible. Records that truly cannot be proxied (like
MX) should point to a different IP than your web origin. - Separate your mail server. Run email on a different host or use a third-party email service so a bounced message never reveals your web origin.
- Remove stale subdomains. Delete old
dev.,staging.,old., anddirect.records that point straight at your server. - Rotate the IP if it already leaked. If your origin IP was public before you added Cloudflare, the historical record already exists. The only complete fix is to move your origin to a new IP and apply the firewall allowlist so the old one is useless even if found.
Origin Protection Checklist
- All web
A/AAAArecords proxied (orange cloud) - No grey-cloud record points to the web origin IP
- Mail server runs on a separate IP or external provider
- Stale dev/staging/direct subdomains removed
- Firewall allows ports 80/443 only from Cloudflare IP ranges
- SSH/admin access restricted to your own IP
- SSL mode set to Full (Strict)
- Authenticated Origin Pulls enabled (if supported)
- Direct access to
https://ORIGIN_IP/no longer serves your site - Cloudflare IP allowlist scheduled for periodic review
Conclusion
Cloudflare is only as strong as your origin configuration. The orange cloud hides your IP from casual lookups, but real protection comes from making your server refuse any connection that did not arrive through Cloudflare. Audit your DNS records, separate your mail server, remove stale subdomains, and allowlist Cloudflare's IP ranges at your firewall. Do those four things and an attacker who discovers your origin IP gains nothing — which is exactly how it should be.