Skip to content

feat: add Cloudflare Tunnel integration#923

Open
lbajsarowicz wants to merge 11 commits into
wardenenv:mainfrom
lbajsarowicz:feature/cloudflared-integration
Open

feat: add Cloudflare Tunnel integration#923
lbajsarowicz wants to merge 11 commits into
wardenenv:mainfrom
lbajsarowicz:feature/cloudflared-integration

Conversation

@lbajsarowicz
Copy link
Copy Markdown
Contributor

@lbajsarowicz lbajsarowicz commented Mar 22, 2026

Summary

  • New warden cf command for tunnel lifecycle management (login, create, delete, status, update, logout)
  • Conditional cloudflared global service (enabled by WARDEN_CLOUDFLARED_TUNNEL_ID in ~/.warden/.env)
  • Dynamic config generation scanning dev.warden.cf.domain container labels
  • New nginx-public.base.yml partial for TRAEFIK_PUBLIC_DOMAIN routing
  • Config auto-regenerates on env up/down/stop/start
  • CHANGELOG entry added

Related PRs

All PRs must be merged together.

Test plan

  • Set up: warden cf loginwarden cf createwarden svc up
  • Configure project with TRAEFIK_PUBLIC_DOMAIN in .env and warden env up
  • Verify warden cf status shows tunnel and connected domains
  • Verify ~/.warden/etc/cloudflared/config.yml has correct ingress rules
  • Verify warden cf update regenerates config
  • Verify warden env down removes domain from config
  • Verify warden cf delete and warden cf logout clean up correctly
  • Verify no-op when WARDEN_CLOUDFLARED_TUNNEL_ID is not set

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a Cloudflare Tunnel integration to Warden, including a new warden cf command, conditional global cloudflared service startup, and automatic tunnel config regeneration based on running environments that opt in via TRAEFIK_PUBLIC_DOMAIN.

Changes:

  • Introduces warden cf subcommands to manage Cloudflare Tunnel lifecycle and local credential/config files.
  • Adds conditional cloudflared global service and generates ~/.warden/etc/cloudflared/config.yml by scanning container labels.
  • Adds an nginx-public Traefik routing partial to opt environments into public-domain routing.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
utils/core.sh Adds regenerateCloudflaredConfig to generate cloudflared config from running container labels and restart cloudflared
commands/svc.cmd Conditionally includes the cloudflared compose file and triggers config regeneration on svc up
commands/env.cmd Adds nginx-public partial opt-in and triggers cloudflared config regeneration on env lifecycle actions
docker/docker-compose.cloudflared.yml Defines the global cloudflared service container and mounts generated config/credentials
environments/includes/nginx-public.base.yml Adds Traefik router labels for TRAEFIK_PUBLIC_DOMAIN and emits dev.warden.cf.domain label
commands/cf.cmd Implements warden cf (login/create/delete/status/update/logout) behaviors
commands/cf.help Adds help/usage text for the new cf command
CHANGELOG.md Documents the new Cloudflare Tunnel integration under UNRELEASED

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread commands/cf.cmd
Comment thread commands/svc.cmd
Comment thread utils/core.sh Outdated
Comment thread utils/core.sh
Prevents trailing \r on Windows/WSL from breaking tunnel operations.
- Remove duplicate regenerateCloudflaredConfig calls in pre-down/pre-up blocks
  (keep only the post-command call when containers are in final state)
- Add preflight warning in svc.cmd when config.yml is missing
- Add varnish-public.base.yml for TRAEFIK_PUBLIC_DOMAIN with varnish enabled
  (varnish.base.yml disables traefik on nginx, so labels must go on varnish)
- Fix comment on docker restart to reflect actual behavior
@bap14
Copy link
Copy Markdown
Member

bap14 commented Mar 23, 2026

Interesting. I'll have to give this a test drive before approving, but seems like an almost no-brainer alternative to ngrok.com.

@navarr
Copy link
Copy Markdown
Member

navarr commented Mar 23, 2026

I think my biggest surprise is that (at least according to Google's AI, because I didn't do more research than that) that Cloudflare offers this free?

I've already merged in the image because there's no potential harm from building it; but the rest I want to spend more time looking over

@lbajsarowicz
Copy link
Copy Markdown
Contributor Author

@navarr I've been using that for more than a year for my Home Assistant and my microservices (e.g. MCPs, self-hosted LMStudio). Finally I found motivation to introduce that to Warden :)

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

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

4 participants