Draw Public Application and Private Network Paths Separately
Two paths reach the same private server, and they fail in different places. A public application path starts at a browser and ends at one hostname. A private network path starts at an enrolled device and ends at an IP range or an internal name. Cloudflare Tunnel carries both, but the control in front of each is different: Access authorizes a hostname, while Gateway authorizes a client and a destination. Treating the tunnel as the security boundary merges two designs that need separate review.
The public path is a hostname contract. A proxied DNS record points the application hostname at the tunnel target, and the edge terminates TLS for that name. The connector receives the request, matches it against an ingress rule, and forwards it to a local service. The origin needs no public address, but the hostname is public and therefore needs an Access application when only named people should reach it.
The private path is a routing contract. An enrolled device sends traffic into Cloudflare, and a route maps a CIDR or an internal hostname to a tunnel. The connector forwards to the private destination using its own network position. No public DNS record and no Access application are involved; the authorization decision belongs to Gateway, and only for devices that actually send traffic through it.
A tunnel is not a trust boundary by itself. One tunnel can carry a public hostname, a private CIDR and a private hostname at the same time. That convenience is also a blast radius: a public web app and a domain controller behind the same connector share a process, a host and a token. Split the tunnel by environment or sensitivity when the public path would otherwise become a stepping stone into the private one.
The connector is outbound-only, which changes the firewall conversation. The host opens outbound sessions to Cloudflare and accepts nothing inbound. Port 7844 carries QUIC by default, with HTTP/2 as the fallback, so an egress firewall that allows only 443 will break the tunnel even when the origin is healthy. The private network needs a route to the origin, not a hole from the internet.
Public access needs no client; private access needs a managed on-ramp. A browser can use the public path with only an Access login. A private CIDR requires the Cloudflare One Client in Traffic mode, with split tunnels that include the range. A private hostname adds DNS mode, Gateway proxying and an initial-resolved-IP range the client must route. Table 1 is the checklist that prevents the familiar "the tunnel is up, so why can't I reach it?"
| Path | Client requirement | Decision point | What breaks without it |
|---|---|---|---|
| Public hostname | Browser only, plus an identity the IdP will authenticate | Access application and ordered policies at the edge | A DNS-only record is not proxied, so neither Access nor the tunnel is in the enforcement path |
| Private CIDR | Enrolled device in Traffic mode; split tunnel includes the CIDR | Gateway network policy after the client routes the packet | The route exists but the client never sends traffic to Cloudflare |
| Private hostname | Enrolled device in Traffic and DNS mode; Gateway proxy enabled; initial resolved IPs routed; local domain fallback adjusted | Gateway DNS, then network, then HTTP policy | The name resolves locally or not at all, so the tunnel is never consulted |
Figure 1 separates the two lanes at the decision point. The left lane asks Access whether this identity may use this hostname. The right lane asks Gateway whether this device and identity may reach this destination. Both lanes meet at a tunnel, but neither decision is made by the tunnel. The dashed denial branches are the controls worth testing.
%%{init: {'theme':'base','themeCSS':'.edgeLabel .label text, .edgeLabel text, .edgeLabel span { fill:#132440 !important; color:#132440 !important; }','themeVariables': {'primaryColor':'#16476A','primaryTextColor':'#ffffff','primaryBorderColor':'#132440','secondaryColor':'#3B9797','secondaryTextColor':'#ffffff','secondaryBorderColor':'#132440','tertiaryColor':'#c4873b','tertiaryTextColor':'#132440','tertiaryBorderColor':'#132440','lineColor':'#5a6e82','textColor':'#132440','titleColor':'#132440','mainBkg':'#16476A','nodeBorder':'#132440','clusterBkg':'#eef3f7','clusterBorder':'#132440','edgeLabelBackground':'#ffffff','actorBkg':'#16476A','actorTextColor':'#ffffff','actorBorder':'#132440','activationBkgColor':'#3B9797','activationBorderColor':'#132440','signalColor':'#5a6e82','signalTextColor':'#132440','noteBkgColor':'#c4873b','noteTextColor':'#132440','noteBorderColor':'#132440','labelBoxBkgColor':'#a8dede','labelBoxBorderColor':'#132440','labelTextColor':'#132440','loopTextColor':'#132440','altBackground':'#f8f9fa','fontFamily':'DM Sans, sans-serif'}}}%%
flowchart TD
B["Public user
browser only"] --> E["Cloudflare edge
public hostname"]
E --> A{"Access application
policy matches?"}
A -- "no session or deny" --> X["403 or login redirect
no tunnel request"]
A -- "allow" --> P["Tunnel: public-app
ingress hostname"]
P --> CP["cloudflared replica
DMZ host"]
CP --> OP["Application origin
private address"]
D["Enrolled device
Cloudflare One Client"] --> G["Gateway
DNS, network, HTTP"]
G -- "no matching allow" --> Y["Blocked by the
catch-all deny"]
G -- "allow plus posture" --> N["Tunnel: private-net
CIDR or hostname route"]
N --> CN["cloudflared replica
VPC host"]
CN --> ON["Private destination
10.20.4.0/24"]
classDef primary fill:#132440,color:#ffffff,stroke:#0b172b;
classDef secondary fill:#16476A,color:#ffffff,stroke:#0f314a;
classDef ok fill:#3B9797,color:#ffffff,stroke:#2a6f6f;
classDef danger fill:#BF092F,color:#ffffff,stroke:#7a0420;
classDef warn fill:#c4873b,color:#132440,stroke:#8a5a1f;
class A,G primary;
class E,P,N secondary;
class CP,CN,OP,ON ok;
class X,Y danger;
class B,D warn;
The public lane can end before the tunnel if Access denies. A 403 at the edge means no request reaches the connector, which is why Access logs and tunnel logs tell different stories. The private lane can end before the tunnel if Gateway denies. A blocked connection consumes no tunnel capacity and leaves no origin log. Reading the right log first is the fastest way to avoid debugging the wrong layer.
One connector can serve both lanes, but the reverse is not true. A public hostname needs a hostname match in the ingress configuration; a private CIDR needs a route and WARP routing enabled on the tunnel. A private hostname needs its own route type and a connector that can resolve the name locally. These are three different capabilities on the same process, and each can be absent while the tunnel still reports healthy.
Read Figure 2 from the left edge inward. The public lane has no device prerequisite, so its control must be strong at the hostname. The private lane has a device prerequisite, so its control can use identity and posture that a browser does not provide. Neither lane inherits the other's guarantee, even when both terminate on the same connector.
A private network is not automatically private. Cloudflare documents that enrolled devices can reach private routes by default, and Gateway policy is what narrows that access. That sentence should be in the change record. A route change is a connectivity change; a policy change is an authorization change; reviewing them together hides which one actually widened access.
Manage Tunnel and Route Configuration with Current Resources
Five objects carry the whole network model. The tunnel is the connector identity. The tunnel configuration holds ingress rules for public hostnames. The virtual network isolates overlapping address space. The CIDR route maps an IP range to a tunnel. The hostname route maps an internal name to a tunnel. A DNS record is the sixth object, and it belongs to the zone rather than to the tunnel.
| Object | Resource in provider 5.28.1 | Scope | What it changes |
|---|---|---|---|
| Tunnel | cloudflare_zero_trust_tunnel_cloudflared | Account | Creates the connector identity, its secret and its management mode |
| Tunnel configuration | cloudflare_zero_trust_tunnel_cloudflared_config | Account, per tunnel | Ingress rules for public hostnames and the WARP routing switch |
| Virtual network | cloudflare_zero_trust_tunnel_cloudflared_virtual_network | Account | Isolates routing tables when CIDRs overlap |
| CIDR route | cloudflare_zero_trust_tunnel_cloudflared_route | Account | Binds a network range to a tunnel, optionally to a virtual network |
| Private hostname route | cloudflare_zero_trust_network_hostname_route | Account | Binds an internal FQDN to a tunnel without a static IP |
| Public DNS record | cloudflare_dns_record | Zone | Points the public hostname at the tunnel target and enables proxying |
Remote and local management are mutually exclusive modes. With remote management, the connector runs with a token and receives ingress and WARP-routing settings from Cloudflare. With local management, a YAML file and a credentials file on the host own that configuration. Terraform can own the tunnel object in both modes, but the configuration resource only makes sense in remote mode.
The mode is a property of the tunnel, not a preference. The config_src attribute chooses between remote configuration and a local file, and the older remote-config flag is deprecated. Choosing local management and then applying an ingress resource creates two owners for the same setting. The plan may look clean while the connector ignores the API value, which is the worst kind of drift: invisible until a host reboots.
The ingress list is ordered and needs a catch-all. The connector evaluates ingress rules from top to bottom and uses the first match. The last rule must match everything, conventionally an HTTP 503 response, so a request for an unknown hostname fails predictably instead of falling through. Remote configuration expresses those rules as ingress_rule blocks; the older ingress spelling is not the 5.x schema.
A CIDR route is a statement about reachability, not permission. The route resource binds a network range to a tunnel and optionally to a virtual network. Any enrolled device that can route the range can use it unless Gateway says otherwise. That is why the route and the policy are separate resources with separate owners: connectivity changes weekly, while authorization changes on a different review cycle.
Overlapping ranges require a virtual network, not a longer prefix. Two routes for the same CIDR in the same virtual network conflict, and the API rejects the second. Put each environment in its own virtual network, then attach each route to the right one. The client selects the virtual network in the Cloudflare One Client, so the isolation is visible to the user rather than hidden in a route table.
Private hostnames avoid the static-IP problem. A hostname route binds an internal FQDN to a tunnel. Gateway answers with an initial resolved IP, rewrites the destination, and the connector resolves the name locally. This works when the application's address is ephemeral. It also has a newer connector and client floor than plain CIDR routing, so version checks belong in the rollout plan.
Public hostnames still need a DNS record and a proxied target. Provider 5.x no longer exposes a CNAME attribute on the tunnel, so construct the target from the tunnel ID. The record must be proxied, or the hostname is not enforced at the edge and no ingress rule, Access policy or Gateway policy is evaluated. A DNS-only record is not a tunnel shortcut; it is an unenforced name.
The target is account-bound. The tunnel subdomain only proxies records in the same Cloudflare account, so a zone in another account cannot borrow it. Keep the tunnel and the public hostname zone under one owner, or the CNAME is a dead end.
Version baseline. Behavior was checked against Terraform CLI 1.17.1 and the Cloudflare provider at 5.28.1 on 6 November 2026. The v5 rename matters here: the tunnel resource moved under the Zero Trust prefix, secret became tunnel_secret, and the CNAME attribute disappeared. Configurations copied from v4 examples will plan against a schema that no longer exists.
| Concern | Remote management | Local management |
|---|---|---|
| Where ingress lives | Cloudflare, read by the connector through its token | YAML on the connector host |
| What the host needs | The tunnel token and outbound connectivity | The token, a credentials file and a reviewed YAML file |
| Terraform surface | Tunnel plus configuration and route resources | Tunnel and routes; no configuration resource |
| Change evidence | Plan diff and API state | Git diff plus the file actually mounted on the host |
| Failure signature | Config resource applied while the tunnel is still local | Dashboard edit ignored, or a host reboot reverts routing |
Figure 3 puts the failure branches where they actually occur. A mode mismatch fails at configuration time. An overlapping route fails at the API. A missing connector fails at the edge with a 1033. A missing catch-all fails only for the hostname nobody tested, which is why it reaches production quietly.
%%{init: {'theme':'base','themeCSS':'.edgeLabel .label text, .edgeLabel text, .edgeLabel span { fill:#132440 !important; color:#132440 !important; }','themeVariables': {'primaryColor':'#16476A','primaryTextColor':'#ffffff','primaryBorderColor':'#132440','secondaryColor':'#3B9797','secondaryTextColor':'#ffffff','secondaryBorderColor':'#132440','tertiaryColor':'#c4873b','tertiaryTextColor':'#132440','tertiaryBorderColor':'#132440','lineColor':'#5a6e82','textColor':'#132440','titleColor':'#132440','mainBkg':'#16476A','nodeBorder':'#132440','clusterBkg':'#eef3f7','clusterBorder':'#132440','edgeLabelBackground':'#ffffff','actorBkg':'#16476A','actorTextColor':'#ffffff','actorBorder':'#132440','activationBkgColor':'#3B9797','activationBorderColor':'#132440','signalColor':'#5a6e82','signalTextColor':'#132440','noteBkgColor':'#c4873b','noteTextColor':'#132440','noteBorderColor':'#132440','labelBoxBkgColor':'#a8dede','labelBoxBorderColor':'#132440','labelTextColor':'#132440','loopTextColor':'#132440','altBackground':'#f8f9fa','fontFamily':'DM Sans, sans-serif'}}}%%
flowchart TD
T["Tunnel resource
config_src set"] --> M{"Management mode?"}
M -- "cloudflare" --> R["Remote config
ingress_rule plus warp_routing"]
M -- "local" --> L["YAML and credentials
on the connector host"]
R --> C["Configuration applied"]
L --> C
C --> RT["Route resources
CIDR or hostname"]
RT --> O{"CIDR overlaps another
route in the same vnet?"}
O -- "yes" --> E1["API rejects the route
create a virtual network"]
O -- "no" --> OK["Route exists"]
OK --> H{"Healthy connector
attached?"}
H -- "no" --> E2["1033 at the edge
status down"]
H -- "yes" --> P{"Public hostname
in the path?"}
P -- "yes" --> IN{"Catch-all ingress
rule is last?"}
IN -- "no" --> E3["502 for an unmatched host"]
IN -- "yes" --> GO["Request reaches the origin"]
P -- "no" --> PV["Private route
Gateway decides"]
PV --> GO
classDef primary fill:#132440,color:#ffffff,stroke:#0b172b;
classDef secondary fill:#16476A,color:#ffffff,stroke:#0f314a;
classDef ok fill:#3B9797,color:#ffffff,stroke:#2a6f6f;
classDef danger fill:#BF092F,color:#ffffff,stroke:#7a0420;
classDef warn fill:#c4873b,color:#132440,stroke:#8a5a1f;
class M,O,H,P,IN primary;
class T,R,L,C,RT,PV secondary;
class OK,GO ok;
class E1,E2,E3 danger;
Order the apply so dependencies are real. Create the virtual network before the route, the tunnel before its configuration and routes, and the DNS record after the tunnel exists. Terraform's graph handles the references you wrote, but it cannot invent a reference you expressed as a literal string. A tunnel ID copied by hand is a dependency the graph cannot see.
Keep secrets out of the plan artifact. The tunnel_secret value is sensitive, but sensitive in Terraform means "redacted from CLI output", not "absent from state". The value is in state and in any saved plan. Use an encrypted remote backend with narrow access, short plan retention, and no plan attachments in tickets.
Provision the Connector Host Through Its Own Owner
The tunnel object and the host that runs it have different lifetimes. Terraform can create the tunnel in seconds and destroy it in one command. The host has an operating system, a package version, a network position and a patching schedule. Give each a separate owner and a separate state. The network team owns the Cloudflare objects; the platform team owns the compute and the service manager.
If the host is Terraform-managed, it belongs in a platform stack. On AWS, an Auto Scaling group with a launch template and an instance role is the usual shape: the group owns replacement, and the secret manager owns the token. The Cloudflare stack should reference the host as an input, never as a resource it creates, so a network change cannot resize or rebuild the fleet by accident.
Never run Terraform from the connector host. The host's purpose is to carry traffic, and its failure mode is losing the network path. If the pipeline that repairs the tunnel also depends on the tunnel, a bad change removes its own recovery route. Run applies from CI or an operator workstation outside the private network, with remote state and short-lived credentials.
The token is a bearer credential for the whole tunnel. Anyone who holds it can run a connector and join the tunnel, so it belongs in a secret manager. Inject it at start through the instance role or a root-readable environment file, and treat every intermediate copy as a leak.
| Leak path | Why it exposes the token | Control |
|---|---|---|
| Launch template or user-data | Readable from instance metadata, the console and boot logs | Fetch from Secrets Manager with the instance role at start |
| Install command line | Persisted in shell history, process listings and unit files | Use an environment file with mode 0600, not an argument |
| Container image or environment | Readable by anyone who can inspect the image or the running task | Inject at runtime from the platform secret store |
| Terraform output or saved plan | Written to state, CI logs and any plan artifact | Read the token out-of-band; never emit it as an output |
| Wrapper script or debug log | Echoes the environment that holds the secret | Redact the variable and alert on token-shaped strings |
Two replicas are the minimum, and they belong in different failure domains. Cloudflare routes traffic to connected replicas, so one host restart should not be an outage. Two replicas in one availability zone survive a process crash but not a zone failure. The cost of the second small instance is usually less than the cost of explaining a single-connector outage.
Pin the connector version and patch it like any other daemon. A latest-tag container or an unversioned package makes every reboot a change window with an unknown payload. Build a golden image or a pinned package version, roll it through the fleet, and keep the previous image for rollback. The tunnel token does not pin behavior; the binary does.
The host needs outbound reachability, not inbound rules. Allow outbound 7844 for QUIC and TCP, plus the HTTPS endpoints used for updates and API calls where your platform requires them. Do not open an inbound port for Cloudflare, because the connector initiates the connection. If an egress proxy is mandatory, configure it explicitly and test the fallback protocol.
Logs are evidence, and they are also a leak surface. The connector normally logs the tunnel ID, connection events and origin errors rather than the token, but a wrapper script that echoes its environment will undo that. Centralize logs, restrict access, and add a detection rule for token-shaped strings. The same rule catches the copy-paste that puts a token in a runbook.
A host owner needs a health signal it can act on. Process alive is weaker than tunnel connected, and tunnel connected is weaker than origin serving. Export the tunnel status and connection count, alert when the count drops below two, and page the platform owner rather than the network team. The runbook starts with "which layer is down", not "restart everything".
| Concern | Owner | Evidence to keep | Change trigger |
|---|---|---|---|
| Tunnel, routes and ingress | Network team | Terraform plan, route list, tunnel status | New application or network segment |
| Connector compute and patching | Platform team | Image version, instance health, restart history | OS or connector release |
| Tunnel token | Security or platform team | Secret version, rotation record, consumer list | Scheduled rotation or suspected exposure |
| Gateway policy | Security team | Rule diff, precedence table, denial log sample | Access review or incident |
| Public DNS record | DNS owner | Record diff, proxy status, certificate state | Hostname launch or retirement |
"Not Terraform on the same host" also means not the same credentials. The provider token that edits Cloudflare should not be readable by the connector host, and the tunnel token should not be able to edit Cloudflare. Separate the two identities, scope the provider token to the resources the configuration owns, and rotate them on different schedules. A compromise of the host should not become a compromise of the account.
A destroy is a network change with a delay. Deleting the tunnel object invalidates the hostname and the routes, but the connector process may keep running until it notices. Terraform does not stop the remote daemon; the host owner must drain or stop it. Put the order in the runbook: remove the route or policy, stop the connector, then destroy the tunnel.
Design Gateway DNS, HTTP and Network Policy by Client Context
Gateway decides for a client, not for a hostname. The inputs are the identity behind the request, the posture of the device, and the destination at the layer being evaluated. That is a different question from Access, which decides whether an identity may use a named application. A private network has no login page, so Gateway is often the only policy in the path.
Client context begins with enrollment. A device that never enrolled does not send traffic through Gateway, so no policy applies and no log entry appears. Enrollment rules, device profiles and client mode decide who is in scope before any rule is written. A policy that looks strict is decorative if the device fleet is not enrolled and locked.
Posture is a separate object with its own lifecycle. A posture check proves something about the device, and a policy references the check's identifier. Create the check first, let it report, then reference it. A rule that references a missing or never-passing check denies silently, which looks like a broken route rather than a policy bug.
DNS policy is the earliest and cheapest denial. It runs on the query, before a connection exists, and can match the domain, the identity and the device posture. Blocking a private zone at DNS prevents the client from learning the initial resolved IP for a private hostname, so the connection never starts. It cannot govern a client that uses its own resolver, which is why network policy still matters.
Network policy is the enforcement floor for private addresses. It matches the destination IP and port, plus identity and posture, after the client routes the packet to Cloudflare. This is the layer that covers SSH, databases, raw IP access and non-HTTP protocols. It also survives a client that ignores DNS policy, because the packet still has to pass through the proxy.
HTTP policy adds application context, at a cost. It can match host, path, method and content, but for HTTPS that visibility depends on the Cloudflare certificate and TLS decryption. Without inspection, do not assume a path rule is protecting anything; the request may be decided at the network layer instead. Use network policy for the guarantee and HTTP policy for the finer decision where inspection is deliberately enabled.
Order is DNS, then network, then HTTP. Each builder has its own precedence list, and the first matching rule in that list decides. Since July 2025, network policy is evaluated before HTTP policy, so a network block cannot be rescued by an HTTP allow. That is the correct security order: the connection decision outranks the request decision.
Default behavior is allow, so default deny is a rule you write. If no explicit rule matches, Gateway allows DNS, network and HTTP traffic. A restrictive design adds a catch-all block at the lowest precedence in each builder and places specific allows above it. The catch-all must be scoped to the private ranges; an unscoped block turns the whole internet off for every enrolled device.
| Builder | Default with no match | Catch-all scope to add | Trap |
|---|---|---|---|
| DNS | Allow | The internal zone, not every domain | Blocking all DNS breaks public resolution |
| Network | Allow | The private CIDRs, not every destination | Blocking all destinations disables the internet |
| HTTP | Allow, unless HTTP settings set a default block | The private hostnames, not every host | An unscoped block catches unrelated SaaS traffic |
Precedence numbers must agree with the list order. Lower numbers evaluate first, and the provider sends the number you set. Keep gaps or contiguous numbers, but keep them stable. Renumbering every rule to insert one creates a diff nobody can review, and the number is part of the contract rather than a dashboard detail.
A policy without enabled = true is a disabled policy. The provider's default is false, so a rule can apply cleanly, appear in the list and decide nothing. Make enablement explicit in every resource review, and add a convention or a plan-time check that the attribute is always present. This is the most common reason a "deployed" Gateway policy has no effect.
Entitlement is not reachability. Gateway group membership is coarse; it says "this person is in the support group", not "this person may read this database". Keep application-level authorization in the application, and use Gateway to remove paths that should not exist. A network allow is a capability, not a business entitlement.
| Layer | Filters value | Example selector | What it can decide | Blind spot |
|---|---|---|---|---|
| DNS | dns | any(dns.domains[*] == "internal.example") | Resolve, block or override a name before a connection exists | A client using its own resolver never asks Gateway |
| Network | l4 | any(net.dst.ip[*] in {10.20.4.0/24}) | Allow or block a destination IP, port and protocol | No hostname, path or content context |
| HTTP | http | http.request.host == "wiki.internal.example" | Allow, block or isolate by host, path, method and content | HTTPS needs inspection before path and content exist |
Figure 4 shows three gates and one bypass. The allowed device passes DNS, network and HTTP because each layer has a matching allow. The denied device passes DNS and stops at the network catch-all, which is why the HTTP rule never runs. The on-network device reaches the private host directly, without a gate or a log; that path is the reason local network segmentation still matters.
Read Figure 4 by asking which gate produced the decision. A DNS block happens before the route is chosen. A network block happens after the client has already selected a route and sent a packet. An HTTP block happens inside an established connection. The log entry, the user-visible error and the recovery step differ for each, so the layer belongs in the incident note.
Keep the client rollout out of the policy module. Device profiles, split tunnels and enrollment rules change on the endpoint team's schedule; policy rules change on the security team's. Put them in different states or at least different owners, and reference stable identifiers between them. A policy apply should not require an MDM change, and an MDM change should not rewrite a firewall rule.
Verify Connection, Denial and Recovery Across the Boundary
A tunnel status is a claim about connectors, not about the origin. Healthy means at least one connector is connected and serving. It does not mean the ingress rule matches or the origin answers. The first check is the tunnel's computed status and active connection count; the second is a request that traverses the whole path; the third is the origin's own health endpoint.
Test the public and private paths from the correct side. A public hostname is tested from the internet with no client, once as an allowed identity and once as a denied one. A private CIDR is tested from an enrolled device, and a private hostname from a device in Traffic and DNS mode. Testing a private path from the connector host proves the origin is alive, not that the policy path works.
The negative tests are the ones that find the missing control. A denied user must be authenticated but outside the allowed group, so the denial comes from policy rather than a failed login. An unenrolled device must fail to reach the private CIDR, which proves the route is not public. A request to the origin's private address from the internet must fail, which proves the tunnel is the only path.
The error points at a layer before it points at an owner. Read the code and the last log entry before restarting anything, because a connector restart erases the evidence for the two cheapest failures.
| Symptom | Likely layer | First check | Safe next step |
|---|---|---|---|
| 1033 at the public hostname | Edge has no healthy connector | Tunnel status and connection count | Restore one connector, then check egress and token |
| 502 from the connector | Connector up, origin refused or unreachable | Origin health from the connector host | Fix the origin or the ingress target, not DNS |
| 503 from the catch-all | No ingress rule matched | Ingress order and hostname spelling | Add or correct the rule, keep the catch-all last |
| Timeout with no Gateway log | Client never sent traffic to Cloudflare | Split tunnel, client mode and route | Fix the client route before touching policy |
| 403 at the edge | Access or Gateway denied the request | The matching policy and identity | Adjust the rule, then re-test the allow path |
Recovery starts with the smallest reversible action. Restart one connector and watch the connection count return. If the tunnel stays down, check egress and the token before touching DNS. If a policy change caused the outage, revert the rule and confirm the allow path before applying a corrected version. A broad "disable Gateway" test destroys the evidence you need.
Token rotation has an overlap, but not the one people assume. Refreshing the tunnel token prevents new connections with the old token while existing connectors stay active. Reinstall half the replicas with the new token, wait for traffic to redistribute, then do the other half. There is no safe rollback to the old token after a refresh, so keep the window short and the second replica healthy.
A connector rotation is a controlled outage only if you measure it. Before draining a host, confirm the other replica is connected and serving. Stop the service, watch the connection count, and run a real request through the path. Bring the host back with the new version or token, then repeat on the other side. Never rotate both replicas in the same maintenance step.
Drift is the last check and the most revealing. Change one route or policy in the dashboard, run a plan, and confirm the diff appears. A clean plan means the object is not owned by the configuration you think owns it. That is how two teams end up "managing" the same tunnel while neither can explain the live rule.
| Check | From where | Pass condition | Failure points to |
|---|---|---|---|
| Tunnel status | API or dashboard | Healthy with at least two active connections | Connector, egress or token |
| Public allowed | Internet, clean browser | Login completes and the origin responds | Access policy or ingress rule |
| Public denied | Internet, authenticated outsider | 403 or deny page, no origin request | Missing deny rule or a bypass record |
| Private CIDR | Enrolled device, Traffic mode | Allowed destination responds, denied range does not | Split tunnel, route or network policy |
| Private hostname | Enrolled device, Traffic and DNS mode | Name gets an initial resolved IP and reaches the app | DNS mode, local domain fallback or hostname route |
| Connector drain | Enrolled device, during rotation | Requests continue through the remaining replica | Single replica or a stale token |
| Drift | CI or operator workstation | Dashboard edit appears as a plan diff | Object owned by another state |
The lab below is a trace, not a smoke test. It checks the allowed path, the denied path and the recovery path against the same tunnel and the same private destination, so the variable is the client context rather than the infrastructure. Run it in a lab account with placeholder addresses; never widen a production route to make a test pass.
Review private connectivity
Status: design-only. Use a lab account, a lab zone and a disposable private host. No production identity provider, customer hostname or real secret is needed. Replace every address and hostname with your own placeholders.
Prerequisites. Terraform CLI 1.17.1, provider 5.28.1, one tunnel, one connector host with outbound access, one enrolled test device, one identity group that contains the allowed tester, and a second authenticated tester outside that group. A private HTTP service that reports its own name and a health endpoint is enough as the origin.
Steps. Create the tunnel in remote mode, add one CIDR route and one private hostname route, and attach the hostname route to the same connector. Add a network allow for the allowed group and the private CIDR, a network block for the same CIDR at a lower precedence, and an HTTP allow for the test hostname in the HTTP builder. Apply, then confirm the tunnel reports healthy with two connections. From the enrolled device, request the private CIDR and the private hostname, first as the allowed tester and then as the outsider. Stop one connector and repeat the request. Refresh the tunnel token, reinstall one replica, and repeat again.
| Check | Action | Pass condition | Failure signal |
|---|---|---|---|
| Tunnel up | Read status and connection count | Healthy, two connections, route present | Inactive, down, or a single connection |
| CIDR allowed | Request the private address as the allowed tester | The origin responds and the network log shows an allow | Timeout before any Gateway log, which points to split tunnel or route |
| CIDR denied | Request the same address as the outsider | The connection is blocked and the log names the deny rule | The outsider reaches the origin |
| Hostname allowed | Request the internal FQDN with DNS mode on | Name resolves to an initial IP, then the origin responds | Local NXDOMAIN or a direct local answer |
| Hostname denied | Repeat as the outsider | Block at DNS or network before the origin | The origin receives the request |
| Connector loss | Stop one replica, repeat an allowed request | The request still succeeds through the other replica | A 1033 or a dropped path |
| Token rotation | Refresh, reinstall one replica, repeat | New connector joins and traffic continues | New connector fails to authenticate |
| Ownership | Edit one policy in the dashboard, run a plan | The diff appears | A clean plan |
Expected observation. The allowed tester reaches the origin over both the CIDR and the hostname. The outsider is blocked with a log entry that names the rule, and the origin sees no request. Stopping one replica leaves the path working. After the token refresh, the reinstalled replica joins while the untouched replica keeps serving. The dashboard edit appears as a plan diff.
Failure check. The lab fails if the outsider reaches the origin, if the private hostname resolves without the client, if stopping one replica causes an outage, if the reinstalled connector cannot join, or if a dashboard edit produces no diff. It also fails if the only evidence is a dashboard screenshot; the status, the log entry and the origin response are the evidence.
Cost and cleanup. The lab uses one tunnel, two small connector hosts or replicas, one route of each type and three policies. Remove the routes and policies before destroying the tunnel, stop the connectors, then destroy the lab host. Delete the temporary group and any test identity at the identity provider.
Evidence to keep. Sanitized tunnel status and connection count, the route list, one allow log and one deny log, the private hostname resolution result, the origin's response, the plan diff for the dashboard edit, and the rotation timestamps. Store the evidence with the lab notes, never with the token.
Close with the three boundaries the configuration must name. Which hostnames are public and which policy protects them, which private ranges or names are routable and which clients may use them, and which owner can change each. The tunnel is only the carrier; the answers live in Access, Gateway and the host's lifecycle. When those three are written down with an owner and a test, the network is governable; when they are not, the tunnel is a hole with a dashboard.
Next in the Series
In AI and Advanced Platform Resources: Verify the Terraform Boundary, we'll explore Evaluate AI Gateway, Vectorize, Hyperdrive and newer platform services without assuming every API operation is declarative infrastructure.