Cloudflare Tunnel
A running cloudflared connector that carries https://llm.example.com from Cloudflare's edge to a loopback port on your server, with TLS at the edge, no inbound firewall hole, API clients authenticated by your gateway keys, and dashboards behind Cloudflare Access.
Scope: this one product: install, configure, run as a service, protect, update, troubleshoot. Tailnet-only access belongs to tailscale, the reverse proxy in front of the gateway to caddy, the gateway to litellm.
Work through the steps in order. Load a reference only when a step names it.
Discover first
Read-only, never prints secrets.
command -v cloudflared && cloudflared --version
systemctl is-active cloudflared 2>/dev/null; systemctl is-enabled cloudflared 2>/dev/null
ls -l /etc/cloudflared ~/.cloudflared 2>/dev/null | sed 's/ [^ ]*\.json$/ <credentials>.json/' # names and modes only
sed -E '/(token|secret|key)/I d' /etc/cloudflared/config.yml 2>/dev/null # config without secrets
cloudflared tunnel list 2>/dev/null # needs cert.pem
ss -tlnp 2>/dev/null | grep -E ':(4000|8080|8088|11434|8000)\b' # what the tunnel should point at
curl -fsS https://api.github.com/repos/cloudflare/cloudflared/releases/latest | jq -r .tag_name
Ask only what discovery cannot show: hostname and zone, who calls the API (browsers, SDKs, CLIs that cannot add headers), whether any request or response takes over two minutes, locally-managed (config file) or remotely-managed (dashboard/token) tunnel.
Decision flow
- No cloudflared: install from Cloudflare's package repo or the GitHub
.deb. -> references/install.md
- No tunnel yet: create it, route DNS, write the ingress file, run it as a systemd service. ->
references/configuration.md
- Clients are SDKs and tools using
Authorization: Bearer <key>: leave the API hostname without Access; the gateway enforces keys. If the hostname must sit behind Access, issue a service token. -> references/access-and-auth.md
- Dashboards or admin UIs: Access application with an identity policy, plus
originRequest.access to make cloudflared verify the token. -> references/access-and-auth.md
- Streaming, long requests, websockets: SSE needs
Content-Type: text/event-stream; the proxy read timeout is 125 s. -> references/streaming-and-timeouts.md
- Needs
/v1/models enriched or a path-specific front: path rule to a local Caddy. -> references/combos/caddy-catalog-front.md
- API behind Access for CI or agents: ->
references/combos/access-service-token-for-api.md
- Metrics, logs, replicas: ->
references/observability.md
- Upgrade or change config: ->
references/updating.md
- 524, 530, 1033, 502, buffering, disconnects: ->
references/troubleshooting.md
Rules
- Ask before changing the system. Installing a service,
tunnel create, DNS routes, Access applications and service tokens need approval and an undo path (cloudflared tunnel delete, remove the route, disable the token).
- Run it as a service. A
nohup or tmux tunnel dies silently and every request then returns HTTP 530 (error 1033).
- Never expose raw engine ports. Ingress points only at the gateway or a loopback reverse proxy bound to
127.0.0.1. Never vLLM, llama.cpp or Ollama directly: they have no real auth.
- Keys stay on. The tunnel is transport. LiteLLM virtual keys (or an Access service token) authenticate API calls.
- Use
127.0.0.1, not localhost, in service URLs. IPv6 ::1 first gives 502.
- Catch-all last. The final ingress rule is
http_status:404; rules match top to bottom and the path is forwarded unchanged.
- Secrets never touch output. Credentials JSON and tunnel tokens are
0600 files (or --token-file); never --token <value> on a command line, never --loglevel debug in shared logs (it logs request headers).
- Verify upstream. Versions, flags, defaults and limits come from developers.cloudflare.com and the GitHub releases at use time.
Workflows
Reference index
references/install.md: apt, .deb, Homebrew, binary names for arm64 and amd64, version check.
references/configuration.md: locally vs remotely managed tunnels, config file, ingress rules, origin parameters and defaults, run parameters, systemd.
references/access-and-auth.md: Access applications, service tokens and headers, strict mode, originRequest.access, what breaks API clients.
references/streaming-and-timeouts.md: SSE buffering, 524, idle timeout, websockets, QUIC vs HTTP/2.
references/observability.md: logs, metrics endpoint, tunnel status, replicas.
references/updating.md: auto-update rules, package updates, config changes without downtime.
references/troubleshooting.md: error table.
references/combos/caddy-catalog-front.md: path rule to a Caddy front for /v1/models.
references/combos/access-service-token-for-api.md: API behind Access for automated callers.
assets/config.yml: ingress template for the API host and a dashboard.
Companion skills
tailscale: tailnet-only access, no public hostname. Install: npx skills add ScaleDockHQ/llm-skills --skill tailscale.
caddy: loopback reverse proxy, model catalog, forward auth. Install: npx skills add ScaleDockHQ/llm-skills --skill caddy.
litellm: the authenticated gateway behind the tunnel. Install: npx skills add ScaleDockHQ/llm-skills --skill litellm.
self-hosted-llms: the full self-hosted stack that uses this tunnel. Install: npx skills add ScaleDockHQ/llm-skills --skill self-hosted-llms.
1---2name: cloudflare-tunnel3description: Cloudflare Tunnel (cloudflared) publishes a local LLM endpoint at a public HTTPS hostname with no open port, optionally behind Cloudflare Access. Use to install cloudflared, write ingress rules, run it under systemd, put a dashboard behind Access, give API clients service tokens, keep SSE streaming working, and fix HTTP 524, 530 or 1033, 502 and buffered streams. Not for tailnet-only access (tailscale).4license: MIT5compatibility: Linux or macOS with bash, curl and jq, and a domain on Cloudflare DNS. Needs a Cloudflare account. Installing a service, creating tunnels, DNS routes and Access policies needs the user's explicit approval.6metadata:7 source: https://skillmd.com/skills/scaledockhq/cloudflare-tunnel8 author: ScaleDockHQ9 version: "0.1.0"10---1112# Cloudflare Tunnel1314A running `cloudflared` connector that carries `https://llm.example.com` from Cloudflare's edge to a loopback port on your server, with TLS at the edge, no inbound firewall hole, API clients authenticated by your gateway keys, and dashboards behind Cloudflare Access.1516**Scope:** this one product: install, configure, run as a service, protect, update, troubleshoot. Tailnet-only access belongs to `tailscale`, the reverse proxy in front of the gateway to `caddy`, the gateway to `litellm`.1718Work through the steps in order. Load a reference only when a step names it.1920## Discover first2122Read-only, never prints secrets.2324```bash25command -v cloudflared && cloudflared --version26systemctl is-active cloudflared 2>/dev/null; systemctl is-enabled cloudflared 2>/dev/null27ls -l /etc/cloudflared ~/.cloudflared 2>/dev/null | sed 's/ [^ ]*\.json$/ <credentials>.json/' # names and modes only28sed -E '/(token|secret|key)/I d' /etc/cloudflared/config.yml 2>/dev/null # config without secrets29cloudflared tunnel list 2>/dev/null # needs cert.pem30ss -tlnp 2>/dev/null | grep -E ':(4000|8080|8088|11434|8000)\b' # what the tunnel should point at31curl -fsS https://api.github.com/repos/cloudflare/cloudflared/releases/latest | jq -r .tag_name32```3334Ask only what discovery cannot show: hostname and zone, who calls the API (browsers, SDKs, CLIs that cannot add headers), whether any request or response takes over two minutes, locally-managed (config file) or remotely-managed (dashboard/token) tunnel.3536## Decision flow37381. **No cloudflared:** install from Cloudflare's package repo or the GitHub `.deb`. -> `references/install.md`392. **No tunnel yet:** create it, route DNS, write the ingress file, run it as a systemd service. -> `references/configuration.md`403. **Clients are SDKs and tools using `Authorization: Bearer <key>`:** leave the API hostname without Access; the gateway enforces keys. If the hostname must sit behind Access, issue a service token. -> `references/access-and-auth.md`414. **Dashboards or admin UIs:** Access application with an identity policy, plus `originRequest.access` to make cloudflared verify the token. -> `references/access-and-auth.md`425. **Streaming, long requests, websockets:** SSE needs `Content-Type: text/event-stream`; the proxy read timeout is 125 s. -> `references/streaming-and-timeouts.md`436. **Needs `/v1/models` enriched or a path-specific front:** path rule to a local Caddy. -> `references/combos/caddy-catalog-front.md`447. **API behind Access for CI or agents:** -> `references/combos/access-service-token-for-api.md`458. **Metrics, logs, replicas:** -> `references/observability.md`469. **Upgrade or change config:** -> `references/updating.md`4710. **524, 530, 1033, 502, buffering, disconnects:** -> `references/troubleshooting.md`4849## Rules5051- **Ask before changing the system.** Installing a service, `tunnel create`, DNS routes, Access applications and service tokens need approval and an undo path (`cloudflared tunnel delete`, remove the route, disable the token).52- **Run it as a service.** A `nohup` or tmux tunnel dies silently and every request then returns HTTP 530 (error 1033).53- **Never expose raw engine ports.** Ingress points only at the gateway or a loopback reverse proxy bound to `127.0.0.1`. Never vLLM, llama.cpp or Ollama directly: they have no real auth.54- **Keys stay on.** The tunnel is transport. LiteLLM virtual keys (or an Access service token) authenticate API calls.55- **Use `127.0.0.1`, not `localhost`,** in service URLs. IPv6 `::1` first gives 502.56- **Catch-all last.** The final ingress rule is `http_status:404`; rules match top to bottom and the path is forwarded unchanged.57- **Secrets never touch output.** Credentials JSON and tunnel tokens are `0600` files (or `--token-file`); never `--token <value>` on a command line, never `--loglevel debug` in shared logs (it logs request headers).58- **Verify upstream.** Versions, flags, defaults and limits come from developers.cloudflare.com and the GitHub releases at use time.5960## Workflows6162- [ ] Install and check the version -> `references/install.md`63- [ ] Create the tunnel, DNS route, `config.yml` from `assets/config.yml`, validate, install the service -> `references/configuration.md`64- [ ] Smoke test: `curl -sS https://llm.example.com/health/liveliness`, an authed `/v1/models`, and a streamed chat completion65- [ ] Protect dashboards with Access -> `references/access-and-auth.md`66- [ ] Verify: the unauthenticated request returns 401 from the gateway, not a login page, and the engine ports are loopback-only (`ss -tlnp`)6768## Reference index6970- `references/install.md`: apt, `.deb`, Homebrew, binary names for arm64 and amd64, version check.71- `references/configuration.md`: locally vs remotely managed tunnels, config file, ingress rules, origin parameters and defaults, run parameters, systemd.72- `references/access-and-auth.md`: Access applications, service tokens and headers, strict mode, `originRequest.access`, what breaks API clients.73- `references/streaming-and-timeouts.md`: SSE buffering, 524, idle timeout, websockets, QUIC vs HTTP/2.74- `references/observability.md`: logs, metrics endpoint, tunnel status, replicas.75- `references/updating.md`: auto-update rules, package updates, config changes without downtime.76- `references/troubleshooting.md`: error table.77- `references/combos/caddy-catalog-front.md`: path rule to a Caddy front for `/v1/models`.78- `references/combos/access-service-token-for-api.md`: API behind Access for automated callers.79- `assets/config.yml`: ingress template for the API host and a dashboard.8081## Companion skills8283- `tailscale`: tailnet-only access, no public hostname. Install: `npx skills add ScaleDockHQ/llm-skills --skill tailscale`.84- `caddy`: loopback reverse proxy, model catalog, forward auth. Install: `npx skills add ScaleDockHQ/llm-skills --skill caddy`.85- `litellm`: the authenticated gateway behind the tunnel. Install: `npx skills add ScaleDockHQ/llm-skills --skill litellm`.86- `self-hosted-llms`: the full self-hosted stack that uses this tunnel. Install: `npx skills add ScaleDockHQ/llm-skills --skill self-hosted-llms`.