← Wiki
2026-11-05 concept cloudflarezero-trustvpnwarptunnelaccesssshself-hostingmcpagents

A private network on Cloudflare Zero Trust instead of a VPN

The short version

I do not run a VPN. I run four things that together do what a VPN did for me: a tunnel that publishes a service without an open port, a login wall in front of every hostname, SSH that needs no key on the server, and a device client that gives my machines private addresses so they can reach each other. All of it is Cloudflare Zero Trust, on the free plan, from one dashboard and one API token.

It is for a solo builder or a very small team with a few machines at home and a VPS, and a handful of people or agents who need to reach some of them. It replaces port forwarding, a WireGuard hub, shared SSH keys and a pile of basic-auth passwords.

Question Answer
Cost $0. The free plan covers up to 50 users (plans page); the paid plan is per seat. I am one user plus a few invited emails
What you need A Cloudflare account, a domain on it, cloudflared or Docker on each machine
What it replaces Open router ports, a self-hosted VPN, shared keys in authorized_keys, shared passwords
What it does not give you A full-mesh network for everyone. Most of what I share is HTTP, and for HTTP no device client is needed
Biggest trap An Access policy that is quietly wider than you think (see “The policy trap”)
Lock-in Total. If Cloudflare is down or changes the free plan, this is all down with it

Two earlier posts use these pieces without explaining them: own-searxng-for-agents (the search I publish and share) and agent-harness-and-always-on-gnome (the always-on VPS that reaches my home Mac). This one is the layer underneath.

Everything below is marked. Measured means I saw it happen on my own account in October or November 2026. Docs means I am repeating Cloudflare’s documentation and did not test it myself.

The pieces and how a request flows

flowchart LR
  P[Person in a browser] --> E{{Cloudflare edge}}
  A[Agent or script] --> E
  E -->|1. Access: who are you?| E
  E -->|2. allowed: forward| T[Tunnel]
  T -->|outbound connection
opened from inside| C[cloudflared on my machine] C --> S[Service on 127.0.0.1]

The point of the split is that most sharing is HTTP, which needs only the first two. WARP comes in when I need SSH or a raw TCP port between my own machines.

Publishing a service so it is never public

The order matters more than any setting. Measured, from how I deploy now:

flowchart TD
  A[1. Create the Access app
for the hostname, attach a policy] --> B[2. Check the policy lists
explicit emails or a group only] B --> C[3. Point the hostname at the tunnel] C --> D[4. Open the URL logged out
must redirect to the Access login] D --> E[5. Open it from an address that is not an allowed email
must be refused]

Create the Access app before the hostname goes live, never after. If the DNS record and tunnel route come first, there is a window in which the service is on the internet with no wall. A parked domain of mine drew 51.7k scanner requests in a week (measured), so a bare window is not theoretical. I do this for every new hostname, including a Worker deployed under a new domain.

Other settings that earned their place (all measured, taken from my account’s exported config):

The policy trap

An Access policy is a list of includes, and the includes are OR’d. I had an app whose policy had a good list of emails and, as a second include, “login method: one-time PIN”. Anyone with an email address passes that. The same goes for “login method: Google” or *@*: it means any Google account on earth. I found and closed it on 4 November 2026 while setting up sharing for the first time (measured).

The rule I keep now: includes are explicit emails or groups, nothing else. If a method restriction is wanted, it goes in require, which is AND’d. A group (me, plus a second one with invited people) lets me add a person once and have it apply to every app that group guards.

After any change, I open each shared URL logged out and confirm it redirects to the login, then confirm the private ones refuse an invited email.

People and agents

flowchart LR
  H[Person] -->|Google login or emailed code
email must be in the policy| AC{Access} AG1[Script or bot] -->|service token headers
Service Auth policy| AC AG2[Claude Code, MCP client] -->|browser login once,
then refresh token| AC AC --> APP[the app]

People open a link, log in with Google or a code sent to their email, and get a session. No device client, no account in my team. I do not enroll another person’s laptop or phone into my WARP team: their whole traffic and DNS would land in my logs. If someone needs a device client for their own machines, it goes into their own team. The one exception is a small box that runs jobs, with a split tunnel that keeps everything else out (see “Machines talking privately”).

Scripts and bots use a service token: a client id and secret sent as CF-Access-Client-Id and CF-Access-Client-Secret headers. The policy that accepts it must have the Service Auth action, and the token has to be listed in it (docs; the shape is non_identity in the API, which I read in my exported policies). The token goes to its owner outside chat and outside git, and the agent keeps it in a Keychain. Mine are valid one year. Revoking a person means deleting their email from the group, revoking their tokens, and revoking their sessions in the Users list.

MCP clients are the third case, and the nicest. Turn on Managed OAuth for the Access app and a person connects with one command and a browser login, with no secret to pass around:

claude mcp add --transport http search https://search.example.com/mcp

My settings (measured): dynamic client registration on, loopback callbacks plus the Claude app’s callback allowed, access token 15 minutes, grant 336 hours (two weeks). Service tokens kept working next to it.

Three traps, all measured:

A side effect of OAuth being on: a non-browser client with no credentials now gets 401 and a WWW-Authenticate header instead of a redirect to a login page. That header is how a client discovers the login by itself.

SSH without shared keys

The usual setup: everyone’s public key in authorized_keys, forever. Mine: nobody has a key on the server.

Access can sit in front of an SSH hostname in two ways, and I use both from a tunnel hostname that points at ssh://localhost:22 on the machine:

Measured constraints worth copying:

One more thing that cost me time, measured: after opening the SSH host in a browser, two other hostnames on the same IPs answered HTTP 421. The SSH host used a wildcard certificate and the others had their own, so the browser reused the open connection for the wrong hostname and Cloudflare refused it. A new window fixes it. The structural fix, if it keeps happening, is to put the SSH host on another zone.

Machines talking privately

When HTTP is not enough, WARP does the VPN part.

flowchart LR
  VPS[VPS
warp-cli, 100.96.x] <-->|WARP to WARP| HOME[Home Mac
100.96.x] HOME --> SVC[search on 127.0.0.1] VPS -. no open SSH port .- NET((internet)) ARM[ARM board on another
home connection] <-->|WARP| HOME

What I run (measured):

A machine’s owner can cut access on their own box with warp-cli registration delete. That is a feature of a shared setup, not a bug.

Traps, in one list

What this does not do

Glossary

Related: own-searxng-for-agents, agent-harness-and-always-on-gnome, tools-and-infrastructure.

Related