Cloudflare Tunnel
Some servers cannot receive traffic on ports 80 and 443: a home lab behind NAT or CGNAT, an instance without a public address, or a provider that blocks inbound traffic by default. With Cloudflare Tunnel, those servers serve your applications anyway. cloudflared runs on the server and only opens connections out to Cloudflare, visitors reach Cloudflare, and Cloudflare sends their requests down the tunnel.
Orbit creates one tunnel for all your servers in a Cloudflare account you connect, and runs cloudflared on the servers you choose. Each of them is a connector of the same tunnel, so with two servers the domains keep answering when one of them is lost.
Guided setup
Settings → System → Cloudflare Tunnel walks through it in three steps, and the If it goes down view on each server links there when visitors depend on the server's address:
- Connect a Cloudflare account, done once, as described below.
- Run it on two servers. Each server you turn on runs
cloudflared, and the list shows when it connects. With two, losing one changes nothing for visitors. - Domains. Your custom domains are sorted by what the tunnel does with them: already through the tunnel; managed by Orbit in Cloudflare and moving as soon as a server runs it; not managed by Orbit, with Let Orbit manage it, which opens the usual automatic DNS setup; and managed at another DNS provider, which stay on A records because the tunnel needs a Cloudflare zone.
Connecting a Cloudflare account
The tunnel belongs to Orbit, not to a workspace, so Orbit's administrator connects the account:
- In the Cloudflare dashboard, create an API token with Account › Cloudflare Tunnel › Edit on the account the tunnel should live in.
- In Orbit, Settings → Cloudflare Tunnel → Connect, paste the token. When the token reaches more than one account, also type the account ID, which is on the account's overview page in the dashboard.
Orbit checks the token by listing the account's tunnels and keeps it in its secret store. Replacing the token later keeps the tunnel. Connecting another account or disconnecting is refused while the tunnel exists: stop it on every server first.
Turning it on for a server
On the server's card in Servers, choose Use Cloudflare Tunnel. Orbit:
- creates the tunnel in Cloudflare the first time, and points it at the cluster's router;
- starts
cloudflaredon that server; - waits until it connects to Cloudflare, for up to three minutes;
- points the domains that can go through the tunnel at it.
cloudflared needs outbound access to Cloudflare on port 7844, over UDP (QUIC) or TCP. When it does not connect, Orbit stops it, removes a tunnel no other server uses, and says so; nothing else changes.
Which domains go through it
While at least one server runs the tunnel, a custom domain goes through it when:
- the workspace connected Cloudflare DNS and Orbit manages the domain's records, and
- the domain's zone is in the same Cloudflare account as the tunnel. Cloudflare only lets a tunnel serve records of its own account.
Orbit replaces the domain's records with a proxied CNAME to the tunnel, and puts the A or CNAME records back when the tunnel stops. The domain's page says when a domain goes through the tunnel.
Previews on your domain follow the same rule: their wildcard record becomes a proxied CNAME to the tunnel when their zone is in the tunnel's account.
These keep pointing at the servers' addresses and only work where those are reachable:
- generated
sslip.ioaddresses, which carry an IP; - domains whose DNS is somewhere else, or in a zone of another Cloudflare account;
- the console's
sslip.ioaddress. Give the console a hostname of yours to reach it through the tunnel.
Cloudflare presents its own certificate to visitors. Inside the cluster, cloudflared reaches the router over HTTPS without checking its certificate, so a domain answers as soon as its record changes. Orbit keeps renewing the domain's Let's Encrypt certificate through the tunnel, so it is ready if the server receives traffic directly again.
The console's address
The console is published on an sslip.io address that carries the main server's IP, so it does not answer when that server only receives traffic through the tunnel. Give it a hostname of yours instead, under Settings → Console address (see The console's address):
- Give the tunnel's token Zone › Zone › Read and Zone › DNS › Edit on the hostname's zone, which must be in the tunnel's account.
- Type the hostname, such as
orbit.example.com, and save.
While a server runs the tunnel, Orbit keeps a proxied CNAME for that hostname, publishes the console on it, and uses it as the console's public address: links in notifications and the GitHub App's webhook move there, and GitLab and Bitbucket webhooks created from then on use it. The record goes away when the tunnel stops on the last server, and the console goes back to its sslip.io address. An empty hostname stops publishing it. With the tunnel running and the hostname active, Keep answering at can turn the sslip.io address off.
What changes with Cloudflare in the path
- Uploads: Cloudflare refuses request bodies over 100 MB on the Free and Pro plans, 200 MB on Business and 500 MB on Enterprise.
- Slow responses: a request that takes more than 100 seconds to start answering ends with Cloudflare's
524error. Move long work to a job and poll for it. - Visitors' addresses: applications see the request coming from the cluster. The visitor's address is in the
CF-Connecting-IPheader. - Caching: Cloudflare may cache static files, such as images and scripts, according to the zone's cache rules.
- Certificates at the edge: Cloudflare's free certificate covers the zone's root and its first level of subdomains.
shop.example.comworks;api.shop.example.comneeds Cloudflare's Advanced Certificate Manager. The same goes for previews: on the free plan they work through the tunnel only when their domain is the zone itself, sincepr-7.preview.example.comis two levels down. - WebSockets work through the tunnel.
When a tunnel disconnects
The server's card shows Tunnel connected or Tunnel disconnected. cloudflared reconnects by itself, and Kubernetes restarts it if it stops. When a server's tunnel has had no connection for two minutes, Orbit marks it disconnected and sends the A server's Cloudflare Tunnel stays disconnected notification, unless the whole server is offline, which has its own notification.
Turning it off
Stop Cloudflare Tunnel on the server's card stops cloudflared there. On the last server that runs it, Orbit first points the domains back at the servers' addresses, then removes the tunnel from Cloudflare. If ports 80 and 443 of the server are closed, those domains stop answering, so open them before.