Skip to content

A stable URL with Cloudflare

A named tunnel gives hytte a fixed address like https://chat.example.com. Your server needs no open ports and no public IP, and Cloudflare provides the certificate. Because the hostname stays the same, passkeys and security keys work, unlike with a quick tunnel.

You need a domain (any registrar) and a free Cloudflare account.

  1. Sign up at dash.cloudflare.com and choose Add a domain (it may also say Onboard a domain). Pick the Free plan.
  2. Cloudflare shows two nameservers. At your registrar, replace the domain’s nameservers with those two.
  3. Wait until Cloudflare marks the domain Active. That usually takes minutes, sometimes a few hours, and Cloudflare emails you when it’s done.
  1. In the dashboard, open Networking → Tunnels (in the Zero Trust dashboard it’s Networks → Tunnels). Zero Trust may ask for a team name the first time and, even on the free plan, for a payment method.
  2. Create a tunnel, choose Cloudflared, and give it a name, e.g. hytte.
  3. Cloudflare shows install commands that contain a long token (the part after --token or service install). Copy the token. You don’t need to run the commands, because hytte starts cloudflared itself.

In the tunnel, add a route of type Published application (older dashboards call it Public hostname):

Field Value
Subdomain chat
Domain example.com
Service HTTP → localhost:8000

If hytte runs with -s (self-signed HTTPS), use HTTPS → localhost:8000 and turn on No TLS Verify under the TLS settings. Cloudflare creates the DNS record for the hostname.

Install cloudflared, then:

Terminal window
export HYTTE_TUNNEL_TOKEN=eyJh… # the token from step 2
hytte -b 127.0.0.1 --domain chat.example.com

The token implies --tunnel and requires --domain. Pass it through the environment rather than --tunnel-token, so it doesn’t show up in ps. With the systemd package, set both in /etc/default/hytte:

Terminal window
HYTTE_OPTS="-b 127.0.0.1 --domain chat.example.com"
HYTTE_TUNNEL_TOKEN=eyJh…

In Docker, run cloudflared as a sidecar instead. See the Compose example, where the service is http://hytte:8000.

Open https://chat.example.com. Create the first account with hytte -u NAME (same -d) and use the printed path with your hostname.

Symptom Likely cause
cloudflared is required for --tunnel-token cloudflared isn’t installed or not on PATH for the hytte user.
Cloudflare error 1033 The tunnel isn’t connected: hytte isn’t running, or the token is wrong.
Error 502 / Bad gateway Wrong service in the route: check the port, and HTTP vs HTTPS (with No TLS Verify for -s).
404 from Cloudflare The hostname doesn’t match a route of this tunnel.
Domain still Pending The nameservers at the registrar aren’t Cloudflare’s yet.
Passkeys not offered --domain doesn’t match the hostname in the browser exactly.