skip to content

How does serving an origin through a Cloudflare Tunnel make the proxy the only way in, and what must you still shut down?

level: middleimportance: should knowfreq 45%

answer

  1. the origin dials out
  2. no inbound port to find
  3. AOP becomes irrelevant
  4. old listeners and records

basics

~20 s

With a Cloudflare Tunnel, cloudflared dials out to Cloudflare, so the origin needs no inbound port and can block all inbound traffic. Still close the old public listener, delete records pointing at the old address, and rotate a leaked IP.

solid answer

~40 s

A Cloudflare Tunnel inverts the connection: the `cloudflared` daemon next to the service opens outbound-only connections to Cloudflare, and requests for the published hostname come back down them. The origin needs no public listener, so its firewall can allow just those outbound connections and refuse every inbound connection, and a leaked address no longer leads to an open web port. The tunnel's `<UUID>.cfargotunnel.com` hostname only serves DNS records in your own account, and published hostnames keep the zone's WAF and Cache Rules. Authenticated Origin Pulls have no effect there, because there is no inbound handshake. What remains is the migration's leftovers: the old public listener and its open inbound ports, `A` or `AAAA` records still pointing at the server, and an address that leaked before the move, which should be rotated.

go deeper

for a junior

Recall that a Tunnel lets the origin connect out to Cloudflare, so it needs no open inbound port and a leaked address finds nothing to connect to.

for a middle

Explain what the Tunnel replaces (the range allowlist and AOP for that hostname), why tunnel hostnames are bound to your account, and that edge rules still apply.

for a senior

Show how you would find and close what a migration leaves behind: the public listener, old address records, other open ports, and an address that needs rotating.

for a principal

Frame when a fleet moves origins to Tunnels rather than AOP, and what availability and ownership the tunnel connectors then demand.

## How the connection is inverted In a classic setup Cloudflare connects **to** the origin, so the origin must listen on a public address and the defender must filter who may connect. A **Cloudflare Tunnel** reverses that. A small daemon, `cloudflared`, runs on the origin or next to it and opens **outbound-only** connections to Cloudflare's network. When a visitor requests the published hostname, Cloudflare sends the request down one of those existing connections, and `cloudflared` hands it to the local service. From the origin's point of view, nothing ever connects in: - The service can listen on a private or loopback address only, reachable by `cloudflared` and nothing else. - The firewall can **block all inbound traffic** and allow only the outbound connections `cloudflared` makes. - A leaked origin address leads to a host with no open web port, so there is nothing to send requests to. The configuration of the tunnel itself, its token, routes and ingress rules, is covered in the material on Tunnel connectors; what matters here is what it does to the origin's exposure. ## What the tunnel already gives you | Concern | IP allowlist and AOP | Cloudflare Tunnel | |---|---|---| | Inbound port on the origin | Open, filtered by source and certificate | None needed | | Proof the traffic came through your account | Only with your own AOP certificate | The tunnel hostname only serves DNS records in your account | | Keeping a range list current | Required | Not needed for inbound traffic | | Edge rules applied | Yes, for traffic through your zone | Yes; published hostnames inherit the zone's WAF, Cache Rules and other Rules | | Authenticated Origin Pulls | The mechanism | No effect; the connector credentials authenticate the link | That second row matters: because the `cfargotunnel.com` hostname only proxies traffic for DNS records in the same Cloudflare account, someone who learns the tunnel's UUID still cannot point their own zone at it. ## What you must still shut down Most failures after a move to a Tunnel are leftovers from the old setup: 1. **The old public listener.** If the web server still listens on its public address with ports 80 and 443 open, the Tunnel is just a second way in. Bind the service to a private or loopback address and close the inbound rules. 2. **Records still pointing at the server.** Remove the old `A` and `AAAA` records, proxied or DNS-only, and point the hostname at the tunnel instead. 3. **Other inbound services.** SSH, database or admin ports left open on the public address are their own exposure; move them behind the tunnel and Access, or onto a private network. 4. **A leaked address.** If the address was known before the move, rotate it once the leftovers are gone; the firewall still has to receive packets it drops, and an old address keeps attracting scans. 5. **Egress, not ingress.** Make sure the firewall allows what `cloudflared` needs outbound, and nothing new inbound. ## Migrating without a gap 1. Run `cloudflared` beside the existing server and route the tunnel to the local service while the old path still works. 2. Point the hostname at the tunnel and watch the origin's log until requests arrive only through `cloudflared`. 3. Bind the service to a private or loopback address and remove the inbound firewall rules for the web ports. 4. Delete the old address records, and rotate the address if it was ever known. 5. Send a request to the old address from outside; nothing should answer. Doing step 3 before step 2 takes the site down; skipping steps 3 and 4 leaves the old way in open beside the new one. ## What the origin should still check - If Cloudflare Access protects the hostname, the origin should still validate the Access JWT, so a misrouted or internal request without one is refused. - Keep the origin's logs: every request should now arrive through `cloudflared`, so a request from anywhere else is a sign that a leftover path is still open. - Run more than one `cloudflared` connector for availability, because the tunnel is now the only way in, and losing it takes the service offline.

  • Does a leaked origin address still matter after moving to a Tunnel?
    Much less for web traffic, because no inbound port answers, but it still matters. The host's firewall has to receive the packets it drops, any other service left listening is still reachable, and the old address keeps attracting scans. Close the leftovers, then rotate the address if it was known before the move.
  • Why does turning on Authenticated Origin Pulls do nothing for a tunnel hostname?
    AOP adds a client certificate to the TLS handshake Cloudflare opens to an inbound listener on the origin. A tunnel hostname has no such listener: requests travel down connections `cloudflared` opened outward, and the tunnel's connector credentials already authenticate them. So AOP settings have no effect there.

A Tunnel is like a shop that bricks up its street entrance and takes deliveries only through a passage it opened itself to the depot: a passer-by who knows the address finds a wall, but an old side door left unlocked makes the wall pointless.

  • With a Tunnel, the origin firewall must allow inbound traffic from Cloudflare's ranges.
  • Tunnel traffic skips the zone's WAF rules, so the origin needs its own filtering.
  • Running a Tunnel closes the server's existing public listener automatically.
  • Turn on Authenticated Origin Pulls to protect a tunnel hostname further.
  • Anyone who learns the tunnel's UUID can route their own hostname to it.