skip to content

Zero Trust Services

Cloudflare Tunnel connects a private service outward to Cloudflare, and Access puts an identity check in front of it. Interviewers ask how this replaces a VPN and what the origin must check.

on this pageshow

explore

questions

12

With Cloudflare Tunnel, how does cloudflared make an internal admin dashboard reachable from the internet without a public IP or an open inbound port?

level: juniorimportance: must knowfreq 45%

answer

  1. who dials whom
  2. long-lived connections held open
  3. egress only, port 7844
  4. CNAME to the tunnel's cfargotunnel.com name

basics

~20 s

cloudflared runs inside the private network and dials out to Cloudflare, holding long-lived connections open. A proxied CNAME points the dashboard's hostname at the tunnel, and Cloudflare sends each request down those connections, so nothing has to accept inbound traffic.

solid answer

~40 s

`cloudflared` runs on a host that can reach the dashboard and opens **outbound** connections to Cloudflare on port `7844`: four long-lived connections to at least two data centers, using QUIC by default and HTTP/2 as the fallback. The public hostname, say `admin.example.com`, is a proxied CNAME to `<UUID>.cfargotunnel.com`. A visitor's request lands at Cloudflare, travels down one of the open connections, and `cloudflared` forwards it to the local service named in its ingress rules, such as `http://localhost:8080`. The firewall only needs to allow egress to Cloudflare and can block all inbound traffic. The tunnel gives connectivity, not authorisation: an access policy still has to decide who gets in.

go deeper

for a junior

Remember the direction: cloudflared dials out to Cloudflare and requests come back down that connection. Name the proxied CNAME to the tunnel's cfargotunnel.com subdomain and the outbound port 7844.

for a middle

Explain the four connections to at least two data centers, QUIC by default with HTTP/2 fallback, and how the edge hands a request to cloudflared, which picks a local service by its ingress rules.

for a senior

Show you can read the signals: Healthy versus Degraded, error 1033 for no connector versus 502 for an unreachable local service, and a firewall that blocks all ingress while allowing egress to 7844.

for a principal

Make the point that connectivity is not authorisation. A tunnel removes the exposed address, but a team still decides who may reach each hostname and what the origin verifies.

## The direction of the connection A classic way to publish an internal service is to give it a public IP address and open an inbound port in the firewall. **Cloudflare Tunnel** turns that around. A small daemon, **`cloudflared`**, runs inside the private network (on the dashboard's own host or on any host that can reach it) and **dials out** to Cloudflare. Cloudflare never connects to a public address on your server. It reuses the connections `cloudflared` already opened and sends requests back down them. The internal admin dashboard in this example keeps a private address only. Nothing on the network boundary accepts a new inbound connection, so a scan of the company's public addresses finds nothing listening for it. ## What cloudflared opens When a tunnel runs, each `cloudflared` instance (a **connector**) sets up its connections like this: - **Four long-lived connections** to **at least two distinct Cloudflare data centers**. If one connection, server or data center fails, the others keep carrying traffic. - They are **outbound only**, to Cloudflare on **port `7844`**. - The transport is set by `--protocol`, whose default `auto` uses **`quic`** over UDP and falls back to **`http2`** over TCP when UDP connections cannot be made. - Running another `cloudflared` for the same tunnel on a second host adds a **replica** with four more connections. ## How a request finds the tunnel 1. You create a tunnel. Cloudflare gives it a UUID and a subdomain, `<UUID>.cfargotunnel.com`. 2. The public hostname, for example `admin.example.com`, gets a **proxied CNAME record** pointing at that subdomain. Adding a route in the dashboard creates the record; for a locally-managed tunnel, `cloudflared tunnel route dns` creates it. 3. A visitor's request reaches the nearest Cloudflare data center, where the zone's security and caching settings apply as for any proxied hostname. 4. Cloudflare sends the request down one of the tunnel's open connections. 5. `cloudflared` matches it against the tunnel's **ingress rules** and forwards it to the local service, such as `http://localhost:8080`. The `cfargotunnel.com` subdomain only proxies traffic for DNS records in the **same Cloudflare account**. Someone who learns your tunnel's UUID cannot point a record in their own account at it and push traffic through it. ## Where cloudflared runs `cloudflared` does not have to run on the dashboard's own machine. It needs two kinds of reach, and nothing more: - **Outbound to Cloudflare**, to open and hold its connections. - **Inward to the service**, on whatever address the ingress rule names. That is `http://localhost:8080` when `cloudflared` shares the host with the dashboard, or a private address such as `http://10.0.4.12:8080` when it runs on a neighbouring host. Besides HTTP and HTTPS, a published hostname can carry TCP, SSH, RDP or a Unix socket. Those non-HTTP services also need `cloudflared` installed on the client for end users to connect. On any one host, only one `cloudflared` can run as a system service, so extra routes go on the existing tunnel rather than a second service. ## What the firewall still does The tunnel does not remove the firewall's job. It makes the job simpler: - **Allow egress** to Cloudflare's tunnel addresses on port `7844`, over TCP and UDP. - **Block all ingress**. Cloudflare calls this a positive security model: only the services named in the tunnel's configuration are reachable. - Port `443` egress is optional. It serves extras such as update checks, and `cloudflared` runs without it. ## Reading status and errors | Signal | Meaning | |---|---| | **Healthy** | The connector is serving traffic over four connections | | **Degraded** | It is serving, but at least one connection has failed | | **Down** | It was connected, but the `cloudflared` process has stopped | | **Inactive** | The tunnel exists, but no connector has ever run | | Error `1033` | Cloudflare cannot find a healthy `cloudflared` to receive the request | | `502 Bad Gateway` | The tunnel is connected, but `cloudflared` cannot reach the local service | A **Healthy** status only proves that `cloudflared` reaches Cloudflare. It says nothing about whether the dashboard behind it is answering. ## What the tunnel does not do - It **connects**, it does not **authorise**. Without an access policy, anyone who knows `admin.example.com` reaches the dashboard. Putting an identity check in front is the job of Cloudflare Access, covered in its own lesson. - A **quick tunnel** (`cloudflared tunnel --url http://localhost:8080`) prints a random `trycloudflare.com` address with no account and no stable identity. That address dies when the process stops, so it suits a demo or a webhook test, not a dashboard a team relies on.

  • What should the firewall rules look like on the host running cloudflared?
    Allow outbound traffic to Cloudflare's tunnel addresses on port `7844` over both UDP and TCP, so QUIC works and the HTTP/2 fallback is available. Block all inbound traffic. Outbound `443` is optional and only serves extras such as update checks. If UDP is blocked, `--protocol auto` falls back to `http2` over TCP.
  • Could someone who learns the tunnel's UUID send their own traffic through it?
    Not by pointing a DNS record at it. The `<UUID>.cfargotunnel.com` subdomain only proxies traffic for DNS records in the same Cloudflare account, so a CNAME in another account goes nowhere. Holding the tunnel's token or credentials file is a different matter: that lets someone run a connector, which is why those are secrets.
  • The tunnel shows Healthy but admin.example.com returns 502. Where do you look?
    Healthy only means `cloudflared` is connected to Cloudflare. A `502` with 'Unable to reach the origin service' means `cloudflared` could not reach the local service in its ingress rule. Check the `cloudflared` logs for the error, then confirm the service is listening on the port and protocol the rule names, for example with `curl` from the same host.

It works like a staff member inside a locked building who phones the switchboard and stays on the line: callers reach them through the switchboard, and nobody ever needs a door opened from the street.

  • Cloudflare connects inbound to the origin through a port opened for the tunnel
  • The dashboard still needs a public IP; the tunnel only hides it
  • The firewall must allow inbound traffic on port 7844
  • A Healthy tunnel status proves the dashboard behind it is answering
  • Anyone who learns the tunnel UUID can point their own domain at it
  • A tunnel by itself decides which users may open the dashboard
open as a page

Behind Cloudflare Access, how should the HR portal's origin validate Cf-Access-Jwt-Assertion, and where do its signing keys and AUD tag come from?

level: middleimportance: must knowfreq 45%

basics

~20 s

Read the JWT from Cf-Access-Jwt-Assertion, verify its RS256 signature with the key whose kid matches one listed at the team domain's /cdn-cgi/access/certs, check iss is the team domain and aud holds the HR application's AUD tag, and reject expired tokens.

open as a page

In Cloudflare Access, how do the Allow, Block, Bypass and Service Auth actions differ, and in what order are an application's policies evaluated?

level: middleimportance: must knowfreq 45%

basics

~20 s

Allow admits matching users, Block refuses them, Bypass switches Access off for matching traffic without logging it, and Service Auth admits service tokens or client certificates without an identity provider login. Bypass and Service Auth run first, then Allow and Block in order.

open as a page

With Cloudflare Access, how does a nightly reporting job with no browser authenticate to one HR endpoint using a service token?

level: middleimportance: must knowfreq 40%

basics

~20 s

Create a service token, attach a Service Auth policy with the Service Token selector to an Access application for that endpoint, and have the job send CF-Access-Client-Id and CF-Access-Client-Secret headers; Access then forwards a JWT whose common_name is the Client ID.

open as a page

In a cloudflared config.yml, how are ingress rules matched against a request, and why must the last rule be a catch-all such as http_status:404?

level: middleimportance: must knowfreq 40%

basics

~20 s

cloudflared tests ingress rules top to bottom and uses the first whose hostname and path regex both match. The final rule must match every URL, typically http_status:404, so requests for unexpected hostnames get a defined answer; the validator rejects a list whose last rule has a hostname or path filter.

open as a page

In Cloudflare Access, what happens when an employee first opens the company wiki, and what reaches the wiki's origin afterwards?

level: juniorimportance: should knowfreq 35%

basics

~20 s

Access stops the request, sends the employee to the team domain's login page to sign in through an identity provider, checks the application's policies, then sets CF_Authorization cookies and forwards each request with a signed JWT in Cf-Access-Jwt-Assertion.

open as a page

How does a locally-managed Cloudflare Tunnel built with cloudflared tunnel create, route dns and run differ from a remotely-managed tunnel run with a token?

level: middleimportance: should knowfreq 35%

basics

~20 s

A locally-managed tunnel keeps its routes in a config.yml on each host and needs cert.pem to create and route it. A remotely-managed tunnel stores its routes on Cloudflare, and the host only runs cloudflared tunnel run --token.

open as a page

An HR portal behind Cloudflare Access trusted every request that reached it, and an audit found requests that never passed Access; how did they arrive, and what closes each path?

level: seniorimportance: should knowfreq 40%

basics

~20 s

They reached the origin directly by IP, or through a hostname, path or Bypass policy no Access application enforced, and the origin trusted headers instead of the JWT. Verify Cf-Access-Jwt-Assertion against the HR AUD tag, then close each route.

open as a page

Through Cloudflare Tunnel, a staging API at https://localhost:8443 returns 502 with an x509 error, then the wrong site once TLS works; which cloudflared originRequest settings fix each?

level: seniorimportance: should knowfreq 30%

basics

~20 s

Set originServerName to the name on the certificate, and caPool to the private CA if cloudflared does not trust it; keep noTLSVerify off. Then set httpHostHeader to the internal site name, because cloudflared forwards the visitor's Host by default.

open as a page

After a second cloudflared replica joined a locally-managed Cloudflare Tunnel on another host, users in one region get 502s and 404s; why, and how do you fix it?

level: seniorimportance: should knowfreq 25%

basics

~20 s

Cloudflare sends each region's traffic to a nearby replica, and each replica resolves localhost and reads config.yml on its own host. Host B lacks the dashboard (502) and the new rule (catch-all 404). Use reachable service addresses and one identical configuration.

open as a page

As the lead replacing a VPN with Cloudflare Access for a wiki and an HR portal, which account rules and session durations do you set, and what must each origin still check?

level: principalimportance: should knowfreq 30%

basics

~20 s

Give each application its own policies and AUD tag, keep HR sessions short and the wiki's longer, turn on Block traffic to all domains in this account and strict service token authentication, review every Bypass, and make each origin verify the Access JWT.

open as a page

As platform lead, how would you set a team's Cloudflare Tunnel standard: remote or local management, who holds tokens and cert.pem, and how replicas are deployed?

level: principalimportance: should knowfreq 22%

basics

~20 s

Default to remotely-managed tunnels changed through a reviewed API pipeline, keep tokens in a secret store and rotate them, keep cert.pem off servers, scope people with per-tunnel roles, and run two or more replicas that can each reach every service.

open as a page