Skip to content

Recipes

Each recipe names its shape — quick or named — and says plainly which parts this guide's lab ran and which are assembled from the documented steps of the earlier chapters. The rule from chapter 1 stands over all of them.

Show a friend the app on your laptop, for ten minutes

Shape: quick. The lab's attempt is chapter 4; the running tunnel is the documented half.

Your app listens on localhost:3000. One command:

cloudflared tunnel --url http://localhost:3000

Send the printed trycloudflare.com address to your friend. When the demo is over, Ctrl-C — the address dies with the command, which for a one-off showing is not a limitation but the entire point. Remember while it lives that the address is a public one: anyone who obtains it can visit, and "obtains" includes your friend forwarding it.

A home service at its own permanent address

Shape: named; chapters 5–7 assembled.

Login once, create the tunnel, write the config with the service's hostname rule and a 404 catch-all, validate it, route the DNS, install the service:

cloudflared tunnel login
cloudflared tunnel create photos
# write ~/.cloudflared/config.yml (chapter 6)
cloudflared tunnel --config ~/.cloudflared/config.yml ingress validate
cloudflared tunnel route dns photos photos.example.org
sudo cloudflared service install

From then on the machine boots into publishing, and the only recurring task is keeping the service itself patched and signed-in-able — the tunnel is the boring part, which is what infrastructure is supposed to be.

Two services, one tunnel

Shape: named. The rule behaviour is the lab-verified part (chapter 6).

One connector can answer for as many names as the ingress list holds:

ingress:
  - hostname: photos.example.org
    service: http://localhost:8080
  - hostname: music.example.org
    service: http://localhost:8090
  - service: http_status:404

Route DNS for each hostname to the same tunnel. Adding a service later is an edit, a validate, and a restart — plus one route dns for its new name.

Publish only the public corner of a service

Shape: named; the fall-through to 404 was proven by the lab's rule queries.

A service whose whole interface lives on one port may still have only one folder fit for strangers. The path rule from chapter 6 makes the distinction at the tunnel, before requests reach the service at all:

ingress:
  - hostname: files.example.org
    path: ^/public/.*
    service: http://localhost:18099
  - service: http_status:404

Everything outside /public/ is answered 404 by cloudflared itself; the origin never sees it. Defence in depth this is not — the service's own controls still matter — but a smaller published surface is a smaller published surface.

A name that says "gone" instead of an error

Shape: named.

Retiring a service gracefully is the catch-all read backwards. Point the hostname at a status and nothing else:

ingress:
  - hostname: old.example.org
    service: http_status:410
  - service: http_status:404

410 Gone is the web's way of saying deliberately retired, which search engines and honest clients treat differently from a failure. The tunnel keeps answering, the origin can be switched off, and the name stops being a mystery error.

A service only your team may reach

Shape: named, plus Cloudflare Access — pointed at, not taught, and documented-only in this guide.

Publish the hostname through the tunnel as usual, then in the Zero Trust dashboard put an Access application in front of it: visitors must sign in (with an email one-time code, or your organisation's identity provider) before Cloudflare lets a request anywhere near your connector. This is the right shape for admin panels and internal tools — public plumbing, private door. The details belong to Access's own documentation; what belongs here is the judgement: if a published service must not be open to everyone, it needs a gate — the service's own sign-in, or Access — and a tunnel alone is not one.