You have an internal web app — a Grafana, a wiki, a Jenkins, a customer staging environment — sitting on a VM with no public IP. The shortcut is to NAT a port through the edge firewall and slap basic auth on it. Cloudflare Tunnel removes that whole class of attack surface: the origin opens an outbound TLS connection to the Cloudflare edge, you point a hostname at the tunnel, and traffic flows in over the existing connection. No inbound port, no public IP, no VPN concentrator to maintain.
How to verify
Before you start, confirm what you have. The tunnel binary is cloudflared, installed from the Cloudflare apt/yum repo or as a single static binary. On the origin:
cloudflared --version
# cloudflared version 2026.4.0 (built 2026-04-...)
# Tunnel must be authenticated against your Cloudflare account
cloudflared tunnel login
# Opens a browser; pick the zone, writes ~/.cloudflared/cert.pem
# List tunnels you already own
cloudflared tunnel list
# Once a tunnel is running, verify the outbound connections
ss -tnp | grep cloudflared
# Four ESTABLISHED connections to 198.41.x.x:7844 (QUIC) — that's healthy
If ss shows fewer than 4 edge connections, the tunnel is degraded and you will see intermittent 530 errors at the edge. The fix is almost always egress firewall: UDP 7844 outbound to Cloudflare’s edge IPs must be allowed.
What’s happening
A tunnel is a long-lived outbound connection from your origin to the Cloudflare edge. The cloudflared daemon dials four QUIC connections to four different colocation facilities and keeps them open. When a request arrives at the edge for a hostname routed to that tunnel, the edge picks one of the four connections, multiplexes the request over it, and cloudflared proxies the request to the origin service named in your ingress rules. The reply travels back over the same connection.
The mental shift is that the origin is no longer a network endpoint — it’s a software endpoint. There is no IP address to scan, no port to fingerprint, no TCP handshake to attempt. Anyone trying to reach the app must come through Cloudflare’s edge, which means WAF, rate limiting, Access policies, and bot management all apply by default. You also stop maintaining a site-to-site VPN: there is no IPsec, no IKEv2, no concentrator to patch.
The procedure
-
Install cloudflared on the origin. On Ubuntu/Debian, add the Cloudflare apt repo and
apt install cloudflared. On Alpine or anywhere static, grab the release binary frompkg.cloudflare.com/cloudflaredand drop it in/usr/local/bin. Verify withcloudflared --version— pin to a known release in your config management. -
Authenticate the host. Run
cloudflared tunnel login. This opens a browser, you pick the zone, and acert.pemlands in~/.cloudflared/. That cert is what authorizes the host to create and operate tunnels against your account. Treat it like an API key — never commit it. -
Create the tunnel. A tunnel is an account-level object identified by a UUID:
cloudflared tunnel create internal-apps # Tunnel credentials written to /root/.cloudflared/<UUID>.json # Created tunnel internal-apps with id <UUID>The
<UUID>.jsonfile contains the long-lived secret the daemon uses to authenticate. Move it to/etc/cloudflared/and lock it down withchmod 600. -
Write the config. At
/etc/cloudflared/config.yml:tunnel: <UUID> credentials-file: /etc/cloudflared/<UUID>.json ingress: - hostname: grafana.internal.example.com service: http://localhost:3000 - hostname: jenkins.internal.example.com service: http://localhost:8080 originRequest: httpHostHeader: jenkins.internal.example.com - hostname: ssh.example.com service: ssh://localhost:22 # catch-all required at the bottom - service: http_status:404Ingress rules are matched top-down. The final
http_status:404is required — without it,cloudflaredrefuses to start. One tunnel can serve many hostnames; you don’t need a tunnel per app. -
Route DNS. Each hostname needs a CNAME at the edge pointing to
<UUID>.cfargotunnel.com. The CLI does it for you:cloudflared tunnel route dns internal-apps grafana.internal.example.com cloudflared tunnel route dns internal-apps jenkins.internal.example.com cloudflared tunnel route dns internal-apps ssh.example.comThese are proxied (orange-cloud) CNAMEs. If you create them manually in the dashboard, make sure the proxy toggle is on or the lookup will return the literal
cfargotunnel.comhostname to clients, which they cannot reach. -
Run as a service. Don’t run
cloudflared tunnel runin a screen session. Install the systemd unit:cloudflared service install systemctl enable --now cloudflared systemctl status cloudflared journalctl -u cloudflared -fThe unit reads
/etc/cloudflared/config.yml. Restart-on-failure is on by default; the log will show all four edge connections coming up within ~5 seconds of start. -
Add Access in front (recommended). A tunnel exposes the app to the public internet via the proxied hostname — anyone who guesses the URL can hit the login page. Put a Cloudflare Access policy on each hostname so a Google/Okta SSO check runs at the edge before the request is multiplexed to the origin. See /en/knowledge-base/cf-access-sso-gate-applications/ for the policy shape.
Common pitfalls
- Egress firewall blocks UDP 7844. Default in many corporate networks; you’ll see the tunnel flap between QUIC and HTTP/2 fallback. Allow UDP 7844 outbound to Cloudflare or accept the slower fallback.
- One credentials file per host. Don’t copy
<UUID>.jsonto a second host expecting HA — both daemons will fight for the same tunnel. Use a replicated tunnel (multiplecloudflaredreplicas authenticated against the same tunnel ID, supported since 2022) or run two separate tunnels with DNS-level failover. - Missing the catch-all ingress rule.
cloudflaredrefuses to start without- service: http_status:404at the bottom of theingress:block. The error in the log is explicit. - Origin app rejects the Host header. Apps like Jenkins or Grafana sometimes check the
Host:header against their configured base URL. SetoriginRequest.httpHostHeaderper hostname or fix the app config. - SSH/RDP without
cloudflared access sshon the client. Routingssh://works, but the client still needs acloudflared access ssh --hostname ssh.example.comProxyCommand entry in~/.ssh/config, otherwise the SSH handshake will not flow over the tunnel.
For client engagements with a mix of internal staging environments and production apps living on private VLANs, we use Cloudflare Tunnel as the default exposure pattern — no VPN concentrator, no inbound NAT, every hostname gated by Access. The runbook above is the template; the per-client work is auditing what’s currently NAT’d through the firewall, retiring the holes, and wiring the SSO policy. That’s the operating model we run in Managed Operations.