Public Origins and Private Service Bindings Are Different Paths
A checkout Worker needs a ledger in an AWS VPC and a customer profile in an Azure VNet. Neither has a public hostname, and neither should.
A public origin is a shopfront on a main road: anyone can approach, so the shop needs its own lock and doorman. A private binding is a service hatch inside a controlled building: the courier needs no street address, but the hatch still checks the parcel label and recipient.
An origin owns the response. A proxied hostname sends traffic through Cloudflare's edge before that origin. A private network is an address space not routable from the Internet, such as an AWS VPC or Azure VNet. A Cloudflare Tunnel is an outbound-only connection from a host inside that network to Cloudflare, so no inbound firewall hole is needed.
Workers VPC builds on the tunnel. A VPC Service catalogs one target: type, tunnel, host or IP, ports, TLS settings. A VPC Network grants access to anything reachable through a tunnel, Mesh network, or virtual network, with the URL choosing the destination at runtime. A binding is the Worker's handle to either. It is a capability, not a general socket: env.PRIVATE_API.fetch(...) reaches only what the configuration allows.
On the public path, DNS points at Cloudflare, the edge terminates client TLS, and Cloudflare connects over the Internet. The origin must prove the request came through Cloudflare using Authenticated Origin Pulls, mutual TLS, or a narrow IP allowlist. On the private path, the Worker calls a binding, Cloudflare routes through the tunnel, and cloudflared reaches a private address. No public DNS record is needed.
Figure 1 shows both paths and where they break.
%%{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
C[Browser or API client] --> E[Cloudflare edge]
E -->|proxied hostname| PUB[Public origin]
PUB -->|public Internet + TLS| AWS1[AWS or Azure public endpoint]
E -->|invokes Worker| W[Worker code]
W -->|binding fetch| S[VPC Service or Network]
S --> T[Cloudflare Tunnel]
T -->|private IP or DNS| PRIV[Private origin]
PUB -.->|missing allowlist or mTLS| BYPASS[Direct bypass path]
T -.->|tunnel down, QUIC blocked, DNS failure| ERR[fetch throws]
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 E,PUB,T,PRIV primary;
class C,AWS1,W,S,ERR secondary;
class BYPASS danger;
Fails open versus fails closed
The public path fails open: when the origin is discoverable and the allowlist is stale, a bypass succeeds quietly and no error is raised.
The private path fails closed. A down tunnel, blocked QUIC, or failed private DNS makes fetch() throw, so the break surfaces at the Worker instead of at the origin.
Figure 2 layers the relationship by trust boundary. The important line is not "inside versus outside Cloudflare"; it is who can name the destination and who can prove the caller's identity. A VPC Service fixes the destination, which resists server-side request forgery. Authorization belongs at the origin, because the tunnel carries no end-user or cloud-provider identity.
Use a public origin when the service serves the open web and can enforce its own edge trust. Use a private binding when it should never be nameable from the Internet. Do not use a private binding merely to avoid TLS or authentication; it solves reachability, not identity.
Workers VPC Services and Networks
Check the plan, role, and cap before designing around it.
Account scope, plan, and service cap
Workers VPC is account-scoped, not a zone setting. At the 2026-11-05 verification date it is beta: a Workers plan is required, usage is free during the open beta, and the cap is 1,000 VPC Services.
The account roles are Connectivity Directory Read, Bind, and Admin. VPC Networks entered public beta on 2026-04-14; confirm the plan, role, and API surface in your own account.
The boundary is narrower than "Cloudflare joins my VPC." For the VPC Service path, Cloudflare does not peer with AWS or Azure or create a route-table entry. It routes a Worker request to a cloudflared connection you run, and that daemon uses the network's own routing, security groups, and DNS. You still own the VPC, VNet, tunnel host, and provider firewall rules.
| Criterion | VPC Service | VPC Network |
|---|---|---|
| Routing scope | One pre-registered host and port | Anything reachable through the bound tunnel, Mesh network, or virtual network |
| Configuration handle | service_id | tunnel_id, network_id: "cf1:network", or cf1:vnet:<UUID> |
| Runtime destination | Fixed by configuration; URL host is not a route | Chosen by the fetch() URL or connect() address |
| Protocols | HTTP and HTTPS via fetch(); TCP for databases through Hyperdrive | HTTP via fetch(); plaintext TCP via connect() |
| Registration cost | One entry per target | None per target |
| DNS behaviour | Hostname with optional resolver IPs, or a literal IP | Resolves through the bound network's routes and DNS |
| Blast radius | Narrow: only that target | Broad: anything the binding permits |
| Best fit | Fixed payment, identity, or admin APIs; cataloged databases | Shared platform networks, many services, overlapping prod and staging addresses |
A payments API at 10.0.1.50:8080 is a good VPC Service: one target, one Worker, a small blast radius. A platform VPC with forty services, blue-green hosts, and a staging network that also uses 10.0.1.50 is a better VPC Network: bind production and staging virtual networks separately and let the URL choose the host. The first minimizes exposure; the second avoids a hundred entries and an update for every backend.
Routing follows the registration, not the URL. Two parts of the request look like routing controls and are not, and the TLS modes trade verification for compatibility.
| Setting | What it controls | Practical consequence |
|---|---|---|
URL host in fetch() | Host header and, for HTTPS, SNI | Never selects the private destination |
| URL port | Nothing | Ignored; the registered port is used |
verify_full (default) | Certificate chain and hostname | Trusts public CAs and Cloudflare Origin CA only |
verify_ca | Chain, but not hostname | Tolerates a name mismatch; weaker than full |
disabled | No certificate checks | Reachability without authentication; diagnostics only |
--app-protocol on a TCP service | postgresql or mysql metadata | What Hyperdrive reads to speak the database protocol |
A service registered at 10.0.1.50:8080 answers every request at that address, even when the Worker asks for https://anything.example/health; the URL host only sets Host and SNI. That is excellent SSRF resistance and a poor fit for runtime routing.
Private CA certificates are not trusted and custom CA upload is unsupported at the verification date. Treat disabled as a temporary diagnostic, never as a production setting.
Figure 3 follows a request through those pieces and shows three failure families: tunnel unavailable, DNS or TLS failure, and origin rejection. The error code tells you which team owns the fix.
%%{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','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'}}}%%
sequenceDiagram
participant W as Worker
participant V as VPC Service
participant T as cloudflared
participant O as Private origin
W->>V: fetch(absolute URL)
V->>V: Resolve service_id to configured host and port
V->>T: Route request through tunnel
alt Tunnel healthy and DNS resolves
T->>O: Connect to private host and port
alt Origin accepts credential
O-->>W: 200 response
else Missing, expired, or wrong-audience credential
O-->>W: 401 or 403 response
end
else Tunnel down or QUIC blocked
T-->>W: fetch throws destination_unavailable or connection_timeout
else Private DNS or certificate failure
T-->>W: fetch throws dns_error or tls_certificate_error
end
One route, one binding, one private origin. The TypeScript panel calls an absolute URL with a five-second timeout, so an outage becomes a clean 503 rather than a hung request; the Bash panel registers the service and deploys the Worker that already binds it.
The script fails fast if any required environment variable is missing, so a half-configured shell stops before it creates anything.
Private DNS stalls first deployments
A hostname-based service needs a resolver that answers inside the private network. Point the service at the tunnel resolver or at explicit resolver IPs; otherwise cloudflared uses its system resolver and the lookup fails.
The tunnel must run version 2025.7.0 or later with QUIC on outbound UDP 7844. A tunnel forced to HTTP/2 can still serve some Zero Trust traffic but blocks Workers VPC DNS resolution, which surfaces as a dns_error.
Tunnel and Workers VPC are not competitors. A Tunnel plus Access is the right shape when people or existing Hyperdrive configurations need a public hostname and an identity policy; Workers VPC is the right shape when a Worker needs a private API or database and you do not want a public hostname or an Access application. The same cloudflared can serve both.
AWS and Azure Origin Authentication and Connectivity
Split by ownership, or the runbook has no owner. Each side holds a different half of the same request.
| Layer | Cloudflare owns | AWS or Azure owns |
|---|---|---|
| Connectivity | Tunnel, VPC Service or Network, Worker binding | VPC or VNet, subnets, route tables |
| Reachability | Routing from the Worker to the tunnel | Security groups, NSGs, network ACLs, private endpoints |
| Authorization | Carries the request; supplies no end-user identity | IAM, SigV4 keys, Entra app registrations, app roles |
| Naming | Service catalog and binding names | Private DNS zones and records |
| Change control | Cloudflare state and credentials | Provider state and credentials |
Reachability comes first on AWS. The tunnel host must reach the origin port, so the security group or network ACL must allow it.
An endpoint condition is not caller identity. An S3 VPC endpoint can require the endpoint in a bucket policy through aws:sourceVpce, but that proves the network path, not which Worker called.
IAM authorization means SigV4. The Worker signs with AWS Signature Version 4, usually through aws4fetch, with the access key in Workers Secrets. AWS rejects signatures more than five minutes from its clock, so scope IAM to one execute-api resource and method and rotate on a schedule you can prove.
Azure mirrors the shape. A private endpoint plus a private DNS zone resolves the FQDN to the private IP, and the NSG must allow the tunnel host to reach it. Authentication is usually an Entra ID app registration using the OAuth 2.0 client credentials flow: the Worker requests a token for the API's application ID URI and presents it as a bearer token.
Validate, do not just present. The API must check issuer, audience, and app role, not merely token presence. The secret belongs in Workers Secrets. A Worker is not an Azure resource, so it gets no Azure managed identity; use an app registration with a secret, certificate, or federated credential you can rotate.
Two credentials, one Worker. The TypeScript panel signs the AWS call and fetches an Entra token for Azure; the other panels carry the bindings and the secrets each path needs.
A payments platform with its ledger in AWS and profile in Azure, called by one Worker, creates two tunnels, two VPC Services, and two bindings. The AWS credential is scoped to execute-api:Invoke on one route; the Azure app registration has one app role on one API. Rotating the Azure secret leaves AWS working; tightening the AWS security group fails only the ledger call. That separation is the point: one cloud's failure does not become a shared credential incident.
Latency has two independent legs: edge to tunnel, and tunnel to origin. A Worker in one region calling a tunnel in another pays both, and a request that fans out to AWS and Azure pays two tunnel paths. Measure each path separately, parallelize independent lookups, and keep chatty calls out of the request path. A private path can be secure and still be the slowest part of checkout.
Check negatives first. No Authorization header should return 401; a token for the wrong audience should return 401 or 403; only the correctly scoped credential should return 200. Run all three before exposing the Worker route.
Reachability is not authorization
A VPC binding proves Cloudflare can route a request to your private service; it does not prove the caller may use it. Workers VPC attaches no AWS IAM principal or Entra ID identity, so the origin must validate a credential the Worker actually presents.
The URL is not the route. A VPC Service does not send traffic to the public hostname in fetch(); it uses the configured private host and port, and the URL host only sets Host and SNI.
A Worker that appears to call a public API may be calling a private service, and an origin that logs only the Host header can look publicly reached. Log the binding, configured target, and credential subject together.
IaC Ownership, Residency, and Failure Boundaries
Infrastructure as code should mirror the ownership split. Cloudflare's Terraform provider manages a VPC Service with cloudflare_connectivity_directory_service (v5.13.0 or later) and attaches it to a Worker version with a vpc_service binding. The AWS or Azure stack manages the network, security groups, private endpoints, DNS zones, and IAM or Entra resources. Keep separate state files and credentials. One state that owns both the tunnel and the provider network gives a bad plan power over the route and the credential, and forces one pipeline to hold both clouds' secrets.
The contract between stacks should be data, not copied strings. Export the tunnel ID and private target from the network stack; read the service ID through a data source or remote-state output in the Cloudflare stack. Do not paste a service ID into three repositories. If you use Pulumi, verify that the provider version you pin exposes the connectivity-directory resource before promising parity with Terraform; the API is shared, but SDK coverage is versioned.
Residency needs the same honesty. The Workers VPC documentation describes routing, scoping, TLS, and limits; it does not promise that a Worker executes in the same jurisdiction as the origin. The tunnel anchors entry into your network, but the Worker runs on Cloudflare's edge, which may be elsewhere. If data cannot leave a jurisdiction, put the tunnel and origin there, restrict what the Worker can read, and verify the contractual commitment with both providers. Do not infer residency from a private origin.
Figure 4 contrasts a single-stack model with a split model, then maps four failures to their owning layer: a stale IP after cutover, a tightened security group, a rotated certificate, and a stopped tunnel.
A cutover can strand the route
A blue-green deploy that changes a private IP is invisible to a VPC Service until someone updates the configured host. A DNS-based service hides the change behind a TTL; a literal IP cannot.
After cutover, call through the binding and check the origin's log for the new instance, not just the Worker's 200. A stale route often returns connection_refused; stale DNS can return dns_error while the application is healthy.
Tunnel capacity is another boundary. Cloudflare recommends two cloudflared replicas on separate hosts per location, each with at least 4 GB RAM and 4 CPU cores, and warns against autoscaling because downscaling breaks existing connections. Replicas provide high availability, not load balancing; requests go to the nearest replica. A single tunnel treated as production turns a host reboot into an outage no retry logic can fix.
Beta is a planning cost
Workers VPC is beta at the planning baseline. Pin the Terraform provider and Wrangler version, record the compatibility date, and re-run reachability tests after upgrades.
Beta does not mean unusable; it means the API and pricing can change. Write that migration cost into the design, not the incident review.
Design a Worker Calling a Private Cloud API
Design a Worker Calling a Private Cloud API
Status: design-only. This exercise was not executed against a hosted account, and no latency, throughput, or cost measurement is claimed.
What you need
- A Workers-plan account, a zone you control, and a token with
Connectivity Directory Adminplus Workers edit. - One AWS VPC or Azure VNet with a private
/healthAPI on a known host and port. - One small Linux VM that can reach the API, runs
cloudflared2025.7.0 or later, and can send UDP 7844 outbound. - A test zone and no production data. The API requires a bearer token; Workers VPC is free during the open beta, but the plan, VM, provider egress, and NAT gateway are not.
Minimal setup. One VM, one API, one remotely-managed tunnel, one HTTP VPC Service, one Worker, and one secret named ORIGIN_TOKEN.
- Start the API on
10.0.1.50:8080. Restrict its security group or NSG to the tunnel VM. Confirm 401 without a token and 200 with the test token. - Install
cloudflared, create a remotely-managed tunnel in the Workers VPC dashboard, and confirm QUIC rather than HTTP/2. - Create the service with
--type http --hostname <private-api-host> --http-port 8080or the IP form, then record the service ID. - Add a
vpc_servicesbinding namedPRIVATE_PAYMENTS_APIwith that ID andremote: true. Set a compatibility date and commit. - Deploy the TypeScript panel, set
ORIGIN_TOKEN, and call/healththrough the Worker. - Stop
cloudflared. - Remove the security-group rule, restore it, and confirm a timeout rather than a 401. A timeout means the path broke; a 401 means the credential broke.
- Cleanup: delete the Worker, service, tunnel, secret, any DNS record, and VM. Confirm in the dashboard that the service entry is gone.
Expected results
| Check | Expected |
|---|---|
/health through the binding | 200 with the origin's JSON and an origin log entry showing Host and token subject; no public DNS record exists |
Stop cloudflared | A bounded 503 and destination_unavailable or connection_timeout |
| Remove the NSG rule | A timeout, not a 401: the path broke, not the credential |
| After cleanup | The service entry is gone from the dashboard |
Cost dimensions. Workers requests and CPU, VM compute and storage, provider outbound transfer and NAT, and any private-endpoint hourly charge. Do not extrapolate the open-beta price past the beta.
Invalid tests. A status-only check cannot distinguish a private call from a public or cached response. A public hostname in fetch() without target verification cannot prove the private path. Production credentials are not a controlled exercise.
Enumerate Reachability, Authorization, and Failure Tests
Run these as a matrix and record evidence. A green Worker response is not enough; the origin log and VPC Service metrics must agree.
- Reachability. Call
/health. Pass: 200 with expected body and an origin log entry. Fail: timeout,destination_unavailable, or a cache hit with no origin entry. - Route pinning. Call with a different hostname in the URL. Pass: the configured target still receives it; the origin sees the URL host only as
Hostor SNI. Fail: a different service responds. - Missing credential. Call without
Authorization. Pass: 401. Fail: 200 or a 503 that hides an authorization bug. - Wrong audience or role. Use a valid token for the wrong API or role. Pass: 401 or 403 with a logged reason. Fail: 200, meaning scope is unchecked.
- Tunnel outage. Stop
cloudflared. Pass: bounded 503 and a bad-upstream metric. Fail: a hang or silent public fallback. - Private DNS failure. Use a hostname that cannot resolve inside the network. Pass:
dns_error, with NXDOMAIN as client error and SERVFAIL or timeout as bad-upstream. Fail: an unclassified exception. - Stale route. Change the origin IP without updating the service. Pass:
connection_refusedordestination_ip_unroutable, and no origin request. Fail: a 200 from an old instance. - Cross-environment isolation. Bind production and staging virtual networks that both use
10.0.1.50. Pass: each reaches its own environment. Fail: cross-read, a blast-radius failure. - Attribution. Filter Zero Trust Network Session Logs by
SourceName. Pass: Worker name and ID appear. Fail: an empty field on a Worker deployed before attribution support; redeploy. - Hyperdrive path. For a TCP service, create a Hyperdrive configuration with
--service-id, bind it, and run a read-only query. Pass: rows return. Fail: averify_fullTLS error from a private CA or hostname mismatch.
If fetch() uses a public hostname, does traffic leave the VPC? No, for a VPC Service: the configured private host and port determine routing, and the URL host only sets Host and SNI. Use a VPC Network when the URL must choose the destination.
Does a VPC binding authenticate the Worker to AWS or Azure? No. It provides a path; the origin still needs SigV4, an Entra token, mTLS, or another credential.
Why not keep the tunnel and the AWS VPC in one Terraform state? The credentials, lifecycle, and blast radius differ; separate states let one cloud rotate or fail without rewriting the other.
Unresolved limitations. No hosted execution was performed, so every operational observation is an expected result or documented error code, not a measurement. Workers VPC is beta; its API, limits, and pricing may change. Custom CA upload is unsupported at the verification date, and the docs describe server-certificate verification but not a Worker client-certificate option; do not design around Worker mTLS without re-checking. connect() over VPC Networks supports plaintext TCP only. Residency is contractual, not a routing guarantee. Pulumi parity with the Terraform resource was not verified.
Verification note. Behavior, roles, limits, and error codes were checked against Cloudflare documentation on 2026-11-05, including Get started (2026-10-12), VPC Services (2026-10-12), VPC Networks (2026-10-29), Binding API (2026-09-16), Limits (2026-09-16), Pricing (2026-09-16), Troubleshooting (2026-09-29), Tunnel (2026-04-22), Hardware requirements (2026-04-22), and Hyperdrive's private-database guide (2026-04-30). No Cloudflare account, tunnel, Worker, AWS VPC, or Azure VNet was provisioned. No CLI, provider, or runtime version was executed; version statements are documentation claims, not tested compatibility results.
Authoritative references.
- Cloudflare Workers VPC: https://developers.cloudflare.com/workers-vpc/
- Workers VPC Get started: https://developers.cloudflare.com/workers-vpc/get-started/
- VPC Services: https://developers.cloudflare.com/workers-vpc/configuration/vpc-services/
- VPC Networks: https://developers.cloudflare.com/workers-vpc/configuration/vpc-networks/
- Workers Binding API: https://developers.cloudflare.com/workers-vpc/api/
- Workers VPC Limits: https://developers.cloudflare.com/workers-vpc/platform/limits/
- Workers VPC Pricing: https://developers.cloudflare.com/workers-vpc/platform/pricing/
- Workers VPC Troubleshooting: https://developers.cloudflare.com/workers-vpc/reference/troubleshooting/
- Workers VPC Terraform: https://developers.cloudflare.com/workers-vpc/configuration/vpc-services/terraform/
- Cloudflare Tunnel for Workers VPC: https://developers.cloudflare.com/workers-vpc/configuration/tunnel/
- Tunnel hardware requirements: https://developers.cloudflare.com/workers-vpc/configuration/tunnel/hardware-requirements/
- Hyperdrive with Workers VPC: https://developers.cloudflare.com/hyperdrive/configuration/connect-to-private-database-vpc/
- Hyperdrive with Tunnel and Access: https://developers.cloudflare.com/hyperdrive/configuration/connect-to-private-database/
- VPC Networks public beta changelog: https://developers.cloudflare.com/changelog/post/2026-04-14-vpc-networks/
- Hyperdrive VPC changelog: https://developers.cloudflare.com/changelog/post/2026-04-29-hyperdrive-vpc-private-databases/
- AWS Signature Version 4: https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_aws-signing.html
- AWS PrivateLink: https://docs.aws.amazon.com/vpc/latest/privatelink/what-is-privatelink.html
- Azure private endpoints: https://learn.microsoft.com/en-us/azure/private-link/private-endpoint-overview
- Microsoft identity platform client credentials: https://learn.microsoft.com/en-us/entra/identity-platform/v2-oauth2-client-creds-grant-flow
Next in the Series
In Turn Cloudflare Traffic Into Useful Evidence, we'll explore Connect aggregate analytics, events, logs, and external investigations.