Skip to content

refactor(cloudflared): read the tunnel token from a docker secret - #303

Merged
dargmuesli merged 1 commit into
mainfrom
refactor/cloudflared/token-secret
Sep 5, 2026
Merged

refactor(cloudflared): read the tunnel token from a docker secret#303
dargmuesli merged 1 commit into
mainfrom
refactor/cloudflared/token-secret

Conversation

@dargmuesli

Copy link
Copy Markdown
Member

TUNNEL_TOKEN is the only credential in the stack passed as an environment variable.
Everything else, including both Cloudflare API tokens Traefik uses for the DNS challenge, already goes through Docker secrets.
The token grants the ability to serve traffic for the tunnel, so as an environment variable it is readable through docker service inspect by anyone with Docker API access, and it sits in .env on disk instead of the swarm's encrypted raft store.

cloudflared reads the token from a file given by --token-file / TUNNEL_TOKEN_FILE and trims surrounding whitespace, so a secret written with or without a trailing newline works.
The secret is declared external: true, matching how the two Traefik tokens are already handled.

Create it before deploying, then drop CLOUDFLARED_TUNNEL_TOKEN from .env:

docker secret create cloudflared-tunnel-token -

BREAKING CHANGE: Create the `cloudflared-tunnel-token` secret before deploying, then drop `CLOUDFLARED_TUNNEL_TOKEN` from `.env`.
@dargmuesli dargmuesli changed the title refactor(cloudflared)!: read the tunnel token from a docker secret refactor(cloudflared): read the tunnel token from a docker secret Sep 5, 2026
@dargmuesli
dargmuesli merged commit 28d7929 into main Sep 5, 2026
8 checks passed
@dargmuesli
dargmuesli deleted the refactor/cloudflared/token-secret branch September 5, 2026 00:54
@maevsi-bot

Copy link
Copy Markdown

🎉 This PR is included in version 21.2.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants