# Cloudflare origin IP bypass: lock your origin to CF ranges

> Attackers bypass Cloudflare by sending requests straight to your origin IP. How to restrict the origin to Cloudflare, add origin pulls or Tunnel, and test it.

Canonical: https://red.run.cloud/learn/cloudflare-doesnt-protect-your-origin-ip · By Timothy Lindblom · Published 2026-11-02 · Updated 2026-11-02

Cloudflare protects only the traffic that goes through Cloudflare. If your origin server answers requests sent straight to its IP address, an attacker can skip the Cloudflare firewall entirely. Fix it by allowing only Cloudflare's published ranges at the server firewall, then add Authenticated Origin Pulls with your own certificate or a Cloudflare Tunnel, and test from outside.

| Fact | Detail | Source |
|---|---|---|
| What Cloudflare filters | Only DNS records with a proxied status route HTTP and HTTPS through Cloudflare | [Cloudflare docs](https://developers.cloudflare.com/fundamentals/concepts/how-cloudflare-works/), checked 24 October 2026 |
| What leaks the origin IP | DNS-only records, historical DNS, mail servers on the same host | [Cloudflare docs](https://developers.cloudflare.com/fundamentals/security/protect-your-origin-server/), checked 24 October 2026 |
| Published ranges | 15 IPv4 and 7 IPv6 ranges, last listed change on 28 September 2023 | [cloudflare.com/ips](https://www.cloudflare.com/ips/), checked 2 November 2026 |
| Strongest fixes | Cloudflare Tunnel, or Authenticated Origin Pulls with your own certificate | [Cloudflare docs](https://developers.cloudflare.com/fundamentals/security/protect-your-origin-server/) |
| WAF and patching | Cloudflare still tells customers to patch PHP with its WAF rules on | [Cloudflare blog](https://blog.cloudflare.com/php-vulnerabilities-waf-protection/), 21 October 2026 |

This page matters most now because many owners read "behind Cloudflare" as "covered" during the PHP2Shell week. The [WAF page](/learn/does-a-waf-stop-php2shell) explains what the rules do. This one is about the door they do not guard.
## Why can an attacker skip Cloudflare?

Cloudflare is a reverse proxy. Visitors reach it because your DNS points them there, and it forwards the request to your server. Cloudflare's own explanation of [how it works](https://developers.cloudflare.com/fundamentals/concepts/how-cloudflare-works/) says traffic routes through it when the record has a proxied status. Nothing in that design stops a person from skipping the DNS step and connecting to the server's address.

If the server accepts that connection, the request arrives with no WAF rules, no bot scoring and no rate limits applied. A flaw such as [the PHP2Shell runtime bug](/learn/php2shell) lives in the PHP runtime on the origin, so the origin is exactly what has to be reachable only through the filter.

<figure class="ln-figure">
<svg viewBox="0 0 720 300" role="img" xmlns="http://www.w3.org/2000/svg" font-family="Geist, sans-serif">
<title>Two paths to an origin server: through Cloudflare, and directly to its IP address</title>
<rect x="0" y="0" width="720" height="300" fill="#FFFFFF"/>
<rect x="24" y="40" width="130" height="56" rx="14" fill="#FFF1EF" stroke="#EAD3CF"/>
<text x="89" y="73" text-anchor="middle" font-size="15" fill="#1A0F0F">Visitor</text>
<rect x="24" y="204" width="130" height="56" rx="14" fill="#FFF1EF" stroke="#EAD3CF"/>
<text x="89" y="237" text-anchor="middle" font-size="15" fill="#1A0F0F">Attacker</text>
<rect x="274" y="40" width="170" height="56" rx="14" fill="#1A0F0F"/>
<text x="359" y="64" text-anchor="middle" font-size="15" fill="#FFFFFF">Cloudflare</text>
<text x="359" y="84" text-anchor="middle" font-size="12" fill="#EAD3CF">WAF, bot rules, rate limits</text>
<rect x="566" y="118" width="130" height="64" rx="14" fill="#C70500"/>
<text x="631" y="146" text-anchor="middle" font-size="15" fill="#FFFFFF">Your origin</text>
<text x="631" y="166" text-anchor="middle" font-size="12" fill="#FFF1EF">web server, PHP</text>
<line x1="154" y1="68" x2="274" y2="68" stroke="#1A0F0F" stroke-width="2"/>
<line x1="444" y1="68" x2="566" y2="136" stroke="#1A0F0F" stroke-width="2"/>
<line x1="154" y1="232" x2="566" y2="168" stroke="#B00500" stroke-width="2" stroke-dasharray="7 6"/>
<text x="360" y="224" text-anchor="middle" font-size="13" fill="#B00500">Direct to the origin IP: no filter</text>
<rect x="500" y="228" width="196" height="44" rx="10" fill="#FFF1EF" stroke="#B00500"/>
<text x="598" y="247" text-anchor="middle" font-size="12" fill="#1A0F0F">Fix: firewall drops everything</text>
<text x="598" y="263" text-anchor="middle" font-size="12" fill="#1A0F0F">that is not from Cloudflare</text>
<text x="214" y="58" text-anchor="middle" font-size="12" fill="#655553">proxied DNS</text>
</svg>
<figcaption>The dashed path never touches Cloudflare. Closing it is a job for the server firewall or the host, not for the Cloudflare dashboard.</figcaption>
</figure>

## How does the origin IP become known?

Cloudflare's [protection guide](https://developers.cloudflare.com/fundamentals/security/protect-your-origin-server/) lists the ways. Historical DNS records are in the public domain. DNS-only records contain the address. Mail servers reveal it in bounce messages. Unprotected DNS configurations give it away.

The [proxy status page](https://developers.cloudflare.com/dns/proxy-status/) is blunt about the second one: with a DNS-only record, Cloudflare returns your server's real address and does not route HTTP or HTTPS through its network. Only A, AAAA and CNAME records can be proxied. MX and TXT records are always DNS-only.

<ul>
<li>A forgotten <code>ftp</code>, <code>cpanel</code>, <code>staging</code> or <code>mail</code> hostname set to DNS-only.</li>
<li>Mail sent from the same server that runs the website.</li>
<li>The IP your site had before it moved to Cloudflare, still unchanged.</li>
</ul>

Cloudflare's advice is to audit DNS-only records, keep mail off the protected server, and rotate the origin IP after onboarding, because DNS records are in the public domain. Direct hits on an origin are also where [bots asking for .env and .git files](/learn/bots-requesting-env-and-git-30-second-check) show up in your logs.

## Which lock should I use?

Cloudflare's guide groups the options by layer and rates each one. The ratings below are Cloudflare's own wording, read on 24 October 2026.

| Option | Cloudflare's rating | What it proves | Cost to you |
|---|---|---|---|
| Allowlist Cloudflare IP ranges at the firewall | "Moderately secure"; the guide says it is vulnerable to IP spoofing | The request came from the Cloudflare network | A firewall you control, and keeping the list current |
| Authenticated Origin Pulls, global | "Very secure" | The request came from the Cloudflare network | A certificate setup on the web server |
| Authenticated Origin Pulls, zone-level or per-hostname | "Very secure" | The request came from your Cloudflare zone | Your own certificate, uploaded and renewed |
| Cloudflare Tunnel | "Very secure" | There is no inbound path to the origin at all | Running the `cloudflared` daemon |

Two things to know before you pick. Cloudflare's [IP address page](https://developers.cloudflare.com/fundamentals/concepts/cloudflare-ip-addresses/) says its ranges are shared by all proxied hostnames. An allowlist therefore proves a request came from Cloudflare, and says nothing about which account sent it. And the [Authenticated Origin Pulls](https://developers.cloudflare.com/ssl/origin-configuration/authenticated-origin-pull/) page says the global mode, which uses a certificate shared across accounts, only guarantees a request is coming from the Cloudflare network. For a guarantee about your own account, use zone-level or per-hostname mode with your own certificate.

Tunnel and Authenticated Origin Pulls cannot be combined. The same page says AOP is incompatible with Tunnel, because a tunnel has no inbound listener to present a certificate to.

## How do I lock the origin to Cloudflare?

This section is for people who control the server firewall. Make a change window, keep console access to the machine, and do the steps in this order.

### Step 1: allow Cloudflare ranges and nothing else on ports 80 and 443

Get the list from [cloudflare.com/ips](https://www.cloudflare.com/ips/), or from the [API endpoint](https://developers.cloudflare.com/api/resources/ips/methods/list/) at `/client/v4/ips`, which returns the IPv4 and IPv6 ranges and an etag you can compare to detect a change. At our check the page listed 15 IPv4 and 7 IPv6 ranges. Cloudflare says the ranges do not change often and that changes are published before they go into production.

```
for r in $(curl -s https://www.cloudflare.com/ips-v4); do ufw allow proto tcp from "$r" to any port 80,443; done
for r in $(curl -s https://www.cloudflare.com/ips-v6); do ufw allow proto tcp from "$r" to any port 80,443; done
```

Then remove any rule that allows 80 and 443 from anywhere. Do this on the firewall at your cloud provider as well, if it has one, because a host firewall and a security group are separate. Re-run the list on a schedule so a changed range does not cut off real visitors. Locking the origin does not change how Cloudflare treats crawlers; if [Googlebot is being blocked by Bot Fight Mode](/learn/cloudflare-bot-fight-mode-blocked-googlebot), that is a separate fix.
### Step 2: keep the real visitor IP in your logs

Behind Cloudflare, your server sees Cloudflare addresses. Cloudflare passes the visitor address in the `CF-Connecting-IP` header. Its [restoring visitor IPs guide](https://developers.cloudflare.com/support/troubleshooting/restoring-visitor-ips/restoring-original-visitor-ips/) says to trust that header only from Cloudflare's ranges, and warns that otherwise a malicious user can supply a fake IP.

In nginx, the [realip module](https://nginx.org/en/docs/http/ngx_http_realip_module.html) replaces the client address only for requests from the trusted addresses you define with `set_real_ip_from`. Use the same Cloudflare list there, with `real_ip_header CF-Connecting-IP`.
### Step 3: add Authenticated Origin Pulls with your own certificate

The [zone-level setup](https://developers.cloudflare.com/ssl/origin-configuration/authenticated-origin-pull/set-up/zone-level/) needs an SSL/TLS mode of Full or higher. The steps are to upload a leaf certificate to Cloudflare, load the matching CA certificate on the origin and set it to accept client certificates, switch the feature on, then make the origin require the certificate.
Check the [encryption mode](https://developers.cloudflare.com/ssl/origin-configuration/ssl-modes/) first. Flexible sends plain HTTP to the origin, and Cloudflare says AOP does not apply in Off or Flexible. It strongly recommends Full or Full (strict).

### Step 4 (alternative): move the origin behind a Tunnel

With [Cloudflare Tunnel](https://developers.cloudflare.com/cloudflare-one/connections/connect-networks/), the `cloudflared` daemon opens outbound-only connections to Cloudflare. Cloudflare's wording is that you can allow only those outbound connections and block all inbound traffic, which blocks access to the origin from anything other than Cloudflare. With no public listener, the direct path in the diagram does not exist.

## What should I ask my host?

If you cannot touch the firewall, send this to your provider.

> Our domain uses Cloudflare. Can you restrict inbound web traffic to this account so that only Cloudflare's published IP ranges can reach ports 80 and 443? Is there any other hostname or IP on this server that answers web requests directly? If our server IP was used before we moved to Cloudflare, can it be changed?

- [ ] I have a written answer from the host, with the date.
- [ ] I know whether the IP can be changed, and what that breaks (mail, FTP, allowlists at third parties).
- [ ] I have listed every other service that calls my origin (payment webhooks, uptime checks, backups).

For the platform-specific questions, see [questions to put to a shared host](/learn/php2shell-shared-hosting-what-to-ask-your-provider). On a cPanel server, [the version question for cPanel hosts](/learn/cpanel-whm-cve-2026-41940-ask-your-host) has its own page, and the rest are in [the other hosting and panel guides](/learn/topics/hosting-panels).

## Am I affected? A three-state self-test

<div class="ln-selftest">
<h3>Am I affected? Where you stand right now</h3>
<p>A scan from outside cannot tell whether your origin accepts traffic that skips Cloudflare. Only a request to the origin address, or your firewall rules, can. Test only servers you own.</p>
<ol>
<li><span class="ln-state ln-state-detected">Detected</span> <strong>A direct request to your origin IP returns your site, a login page or a web server error page.</strong> The origin accepts traffic that skips Cloudflare. Close it today with the firewall steps, and check the rest of the server for the patches the WAF was covering for.</li>
<li><span class="ln-state ln-state-unknown">Unknown</span> <strong>You do not know the origin IP, your host manages the firewall, or you have never sent a direct request.</strong> This is the common case. Find the IP, run the test below, and ask the host the question above.</li>
<li><span class="ln-state ln-state-confirmed">Confirmed by owner evidence</span> <strong>You hold the firewall rule list limited to Cloudflare ranges, plus a direct request that timed out or was refused after the change.</strong> The direct path is closed for that address on those ports, as of the date of the test. DNS-only records and other IPs still need their own check.</li>
</ol>
<p>No scan, ours included, moves you from "unknown" to "confirmed".</p>
</div>

The direct test is one command, run from a machine outside your own network, against your own server. Replace the placeholders.

```
curl -sk -m 10 -o /dev/null -w "%{http_code}\n" --resolve example.com:443:ORIGIN_IP https://example.com/
```

A status code means the origin answered. An empty result or a timeout means the connection was dropped. Repeat on port 80, and on any hostname you serve from that IP. With Authenticated Origin Pulls enforced, a request without Cloudflare's client certificate should be rejected by the web server.

## Does locking the origin make PHP patching optional?

No. Cloudflare's [PHP2Shell post](https://blog.cloudflare.com/php-vulnerabilities-waf-protection/) of 21 October 2026 says its WAF rules are on automatically for all plans with the WAF deployed, and that paid customers should confirm the Managed Ruleset is in block mode. It also says customers should still patch their PHP, with the WAF as an additional layer. The post does not discuss direct-to-origin traffic.

Treat the three layers as separate jobs, in the same order a [PHP fix](/learn/php2shell-fix-patch-php-runtime) is: the runtime is patched and restarted, the origin accepts only Cloudflare, and the WAF is in block mode. The same logic applies to plugin flaws, such as the one covered in [LiteSpeed Cache behind a CDN](/learn/litespeed-cache-behind-cdn-cve-2026-3375), where the proxy changes what the server sees.

## What can still go wrong after the lock?

- A DNS-only record on another subdomain still returns the real IP.
- A second IP on the same server serves the same site and was not in the rule.
- The allowlist is never refreshed after Cloudflare changes a range.
- Mail goes out from the web server and shows its address in message headers.
- Port 22 or a [control panel port](/learn/cyberpanel-shadowpanel-ai-scanner-endpoints) is open to the world and was never part of this change.

If you want an outside view of what your site shows, the free scan reads the stack your site serves and matches each version to known vulnerabilities. It is a lookup. It does not test whether your origin accepts direct requests, so the test above stays yours to run.

## Questions people ask

### I'm behind Cloudflare. Does that mean my server is protected?

Only for traffic that goes through Cloudflare. If someone sends a request to your server's own IP address, Cloudflare never sees it, so its firewall rules and bot checks do not apply. Whether that works depends on whether your server answers requests from outside Cloudflare.

### How do I check whether my origin is reachable without Cloudflare?

From a machine that is not on your own network, send a request to your origin IP and give your domain as the host name. If you get your site, a login page or an error page from your web server, the origin accepts direct traffic. A timeout or a refused connection is what you want to see.

### Is allowlisting Cloudflare IP ranges enough?

It stops ordinary direct requests, and Cloudflare rates it moderately secure. The ranges are shared by every proxied hostname, so the rule shows a request came from Cloudflare and says nothing about which account sent it. Authenticated Origin Pulls with your own certificate, or a Tunnel, closes that gap.

### Will locking the origin to Cloudflare break my site?

It can, if you forget the other things that reach your server: a health check, a payment webhook, your monitoring, or an office IP used for admin work. List those first, allow them on purpose, and keep console access to the server open while you test.

### Can I do this on shared hosting where I have no firewall?

Usually not yourself. Ask your host whether the account can be limited to Cloudflare traffic, and whether the server IP can be changed after you moved to Cloudflare. On many shared plans the answer is a no, and then the WAF is one layer and the host's patching matters more.

### My DNS changed to Cloudflare months ago. Is my old IP still a problem?

It can be. Cloudflare says DNS records are in the public domain, and it advises rotating the origin IP after onboarding. If the IP your site had before Cloudflare is still the IP of the server, a record of it may exist outside your control.


## Sources

1. [Cloudflare docs: Origin server protection](https://developers.cloudflare.com/fundamentals/security/protect-your-origin-server/): Recommended protections by layer, how origin IPs leak, rotating the origin IP after onboarding. Checked 24 October 2026.
2. [Cloudflare docs: Cloudflare IP addresses](https://developers.cloudflare.com/fundamentals/concepts/cloudflare-ip-addresses/): Ranges are shared by all proxied hostnames; allowlist guidance. Checked 24 October 2026.
3. [Cloudflare IP ranges (cloudflare.com/ips)](https://www.cloudflare.com/ips/): The published list: 15 IPv4 and 7 IPv6 ranges at our check on 2 November 2026.
4. [Cloudflare API: list IP ranges (/client/v4/ips)](https://developers.cloudflare.com/api/resources/ips/methods/list/): Programmatic list with an etag, so a script can detect changes.
5. [Cloudflare docs: Authenticated Origin Pulls](https://developers.cloudflare.com/ssl/origin-configuration/authenticated-origin-pull/): Global, zone-level and per-hostname modes; the shared certificate limit; incompatibility with Tunnel.
6. [Cloudflare docs: Zone-level Authenticated Origin Pulls setup](https://developers.cloudflare.com/ssl/origin-configuration/authenticated-origin-pull/set-up/zone-level/): Prerequisites and the four setup steps.
7. [Cloudflare docs: SSL/TLS encryption modes](https://developers.cloudflare.com/ssl/origin-configuration/ssl-modes/): Flexible sends plain HTTP to the origin; Full or Full (strict) recommended.
8. [Cloudflare docs: Cloudflare Tunnel](https://developers.cloudflare.com/cloudflare-one/connections/connect-networks/): Outbound-only connections, no publicly routable IP, block all inbound traffic.
9. [Cloudflare docs: Proxy status](https://developers.cloudflare.com/dns/proxy-status/): DNS-only records return your real IP to anyone who queries them.
10. [Cloudflare docs: How Cloudflare works](https://developers.cloudflare.com/fundamentals/concepts/how-cloudflare-works/): Only proxied traffic routes through Cloudflare.
11. [Cloudflare docs: Restoring original visitor IPs](https://developers.cloudflare.com/support/troubleshooting/restoring-visitor-ips/restoring-original-visitor-ips/): CF-Connecting-IP and why to trust it only from Cloudflare ranges.
12. [nginx docs: ngx_http_realip_module](https://nginx.org/en/docs/http/ngx_http_realip_module.html): set_real_ip_from defines the trusted addresses.
13. [Cloudflare blog: PHP2Shell WAF protection (21 October 2026)](https://blog.cloudflare.com/php-vulnerabilities-waf-protection/): Cloudflare tells customers to patch PHP even with the WAF rules on.
