Multiple hostnames/domains with locally managed tunnels?

I'd like to locally manage tunnels programmatically via the CLI. I want it to be able to route requests from multiple domains and subdomains to different sites that are behind a Traefik router.

When I cloudflared tunnel login, it asks me to select a zone/domain. Let's say that I select nick.com

I can then create a tunnel with cloudflared tunnel create nick If i then run cloudflared tunnel list, it shows various tunnels that I've created previously - both via the dashboard and CLI.

If I create a route cloudflared tunnel route dns nick 1.nick.com, i get the response Added CNAME 1.nick.com which will route to this tunnel tunnelID....

If I create a route cloudflared tunnel route dns nick 2, i get the response Added CNAME 2.nick.com which will route to this tunnel tunnelID.... So, the tunnel seems to very much be tied to a specific domain (nick.com).

If I then run cloudflared tunnel route dns othertunnel 1.othertunnel.com, i get the response Added CNAME 1.othertunnel.nick.com which will route to this tunnel tunnelID....

So, it seems like when I am logged in via cloudflared CLI, even though you can see your account's different tunnels, you can only actually use one of them at a time. Moreover, even if you try to create a route on a different tunnel, it'll get created on the one you are currently logged-in to. Is this accurate?

As far as I'm aware, if we use remote-managed tunnels, we can create routes with any of our domains. So, how are we supposed to do something similar with locally managed tunnels? I'm trying to make it all programmatic, so that I can integrate it into the fantastic open-source DDEV (https://ddev.com/) development environment, which is a wrapper around docker for developing with pretty much any PHP CMS or Framework I really don't want people to have to keep going to their dashboard to manually change things - it should just be a CLI command that magically does all the tunnel routing.

Any suggestions? Thanks!
DDEV
Local development environments in seconds. Customize, share, and extend with ease.
Was this page helpful?