Skip to content

feature: 5Stack can manage the panel's Cloudflare zone - #718

Open
lukepolo wants to merge 20 commits into
mainfrom
feature/agent
Open

lukepolo wants to merge 20 commits into
mainfrom
feature/agent

Conversation

@lukepolo

@lukepolo lukepolo commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

5Stack can now manage a panel's Cloudflare zone with one scoped API token, so DNS, the proxy and HTTPS are set up for the owner while certificates stay on cert-manager's HTTP-01 check.

  • utils/cloudflare_setup.sh (plan, records, proxy, status, fix, tiered-cache): records carry a 5Stack comment, other people's records are only replaced after a yes, MX/TXT are never touched, a CAA without Let's Encrypt is warned about, and CLOUDFLARE_ZONE keeps it to the picked zone.
  • Every hostname is proxied except DEMOS_DOMAIN, GAME_STREAM_DOMAIN and TURN; Worker hostnames are left alone; names deeper than the free certificate (or off port 443) stay DNS-only.
  • Rules are added or patched by ref, never by replacing an entrypoint: 5stack_panel and 5stack_panel_acme (no security challenge on /.well-known/acme-challenge/), 5stack_panel_no_cache, and the Redirect Rule 5stack_panel_https, which sends plain HTTP to HTTPS except the challenge path, after which Always Use HTTPS goes off; Bot Fight Mode stops the proxy step, and other people's Redirect or Page Rules that catch the path are named.
  • update.sh re-syncs records before the apply and turns the proxy on only after certificates exist, host by host, sending a host back to DNS only on a 52x or when http://<host>/.well-known/acme-challenge/5stack-check doesn't get the panel's own answer (the new acme-check route) through Cloudflare.
  • The key stays in overlays/local-secrets/cloudflare-secrets.env on the host, outside every overlay, or in Vault kv/cloudflare; there is no DNS-01 solver and no Cloudflare Secret in 5stack.
  • setup-env.sh asks "Set up DNS, proxy and SSL automatically?" (or --cloudflare-managed) and offers Cloudflare's token page with the permissions filled in; ./cloudflare.sh does it for an existing install.

utils/cloudflare_setup.sh puts the panel's hostnames on Cloudflare with one
scoped API token: DNS records (ours carry a comment; anyone else's are only
replaced after a yes), the orange cloud on every hostname except demo uploads
and TURN, a Configuration Rule with HTTPS Full (strict), a Cache Rule for live
data, and read-only checks that stop on Bot Fight Mode. Names deeper than
Cloudflare's free certificate covers stay DNS-only.

With CLOUDFLARE_MANAGED=true, update.sh re-syncs the records before the apply
and turns the proxy on once certificates are ready, rolling a host back on a
52x. cert-manager proves the zones through a Cloudflare DNS-01 solver ahead of
HTTP-01. setup-env.sh asks for it, and ./cloudflare.sh adds it to an existing
install.
lukepolo and others added 19 commits November 3, 2026 09:23
…ideo stays off the plain proxy and the server address stays hidden (#722)
…Encrypt's check through

The DNS-01 solver, the cloudflare-secrets Secret and the Vault ExternalSecret are gone, so the
Cloudflare key is never in the cluster: the engine reads it from the host's local secrets file or
from Vault kv/cloudflare with the vault CLI. Setup turns Always Use HTTPS off behind a 5Stack
Redirect Rule that sends everything but /.well-known/acme-challenge/ to HTTPS, keeps security
challenges off that path, names other rules that catch it, and keeps a host's proxy on only when
an acme-check request gets the panel's own answer through Cloudflare.
…panel beside the https-redirect

The acme-check Ingress is applied with the rest of the routing layer, and the fresh-install test
checks that /.well-known/acme-challenge/5stack-check reaches the panel with its X-5Stack-Check
header on every host while other challenge paths still redirect.
…nel-api.example.com beside panel.example.com
…is on, and the free plan puts every address one level deep
…for a subdomain panel, and recommends it on Cloudflare's free plan
…s still creating (#736)

kubectl wait fails at once on a CRD that doesn't exist yet, so install_traefik raced k3s's gateway-api-crd release; it now waits for each CRD to appear before waiting for it to be established.

(cherry picked from commit 343eaee)
…nstall skips it, and no kubectl exec can hang an update

The step sat silent for up to five minutes while the first start pulled the image. A panel with no timescaledb volume yet has nothing to update, and every kubectl exec in the update path (the extension queries, the PG_VERSION reads, vacuumdb, the signed clip link check) now runs under a time limit.
…, and a key the 5Stack service passes isn't reported missing

With REVERSE_PROXY=true the panel issues no certificates, so the engine skips the Let's Encrypt check through Cloudflare, its challenge-path and redirect rules and Always Use HTTPS, and keeps only the origin check. setup-env.sh keeps REVERSE_PROXY=true alongside CLOUDFLARE_MANAGED, and only warns about a missing token when neither CLOUDFLARE_API_TOKEN nor the secrets file has one.
…d never adds the shared 10.42 lines for it

PANEL_POD_RANGE, PANEL_SERVICE_RANGE and PANEL_TAILSCALE_TAG in .5stack-env.config set the routes, grants, tag owner and key tags game-node-server-setup.sh writes, and the k3s it installs keeps those ranges. Without them, a cluster whose pods are outside 10.42.0.0/16 is refused.
…, with the zone rules set first

The records step now sets the zone rules (configuration, cache and, for a panel issuing its own certificates, the ACME and HTTPS redirect rules) and then creates or updates every hostname the plan proxies with the orange cloud on. Demo uploads, streams, TURN and anything else the plan keeps direct stay DNS only. An existing DNS-only 5Stack record for a proxied hostname is turned orange on the next run. The late proxy step keeps its origin check and, outside reverse-proxy mode, its ACME check, and still puts a failing hostname back to DNS only. A zone that fails the readiness check gets its records as they are, without rules or the orange cloud.
….sh's records and proxy steps

With CLOUDFLARE_RECORDS_SET=true, update.sh leaves out "Updating the panel's Cloudflare records" and "Putting Cloudflare in front of the panel". It only checks each proxied host through Cloudflare and puts one that answers 52x back to DNS only. The stream relay Worker step still runs. Without the variable nothing changes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant