cloudflare / cloudflared

Cloudflare Tunnel client (formerly Argo Tunnel)
https://developers.cloudflare.com/cloudflare-one/connections/connect-apps/install-and-setup/tunnel-guide
Apache License 2.0
8.75k stars 773 forks source link

💡When running `cloudflared tunnel route dns tunnel-name tunnel.x.com` use the x.com zone #1295

Open remorses opened 1 month ago

remorses commented 1 month ago

Describe the feature you'd like Currently to create a tunnel you have to run the following commands (dx is already very bad, should be 1 command)

cloudflared tunnel  create tunnel-name
cloudflared tunnel route dns tunnel-name tunnel.example.com
cloudflared tunnel run --url http://localhost:5467  tunnel-name

This won't create a tunnel on tunnel.example.com if for some reason you used the cloudflared on another domain previously (for example x.com), instead it will create one on tunnel.example.com.x.com

Describe alternatives you've considered Use the website with domain example.com if i am trying to create a tunnel there, not tunnel.example.com.x.com

Additional context Maybe you have to run cloudflared tunnel login again? But there is only 1 global cloudflared config at /Users/user/.cloudflared/cert.pem, this doesn't make sense

remorses commented 1 month ago

I think i managed to get this working, congrats on making the most user hostile cli i ever used, and i used a lot of clis

  1. Create the tunnel on the cloudflare website, the cli is useless, it will use whatever domain you selected the first time you logged in
  2. Now you have to download another tunnel token even if you already are logged in, because why not
  3. To do this run cloudflared tunnel token --cred-file .cloudflared/tunnel.json tunnel-name
  4. Now create a file .cloudflared/config.yml and add the contents
    tunnel: tunnel-name
    credentials-file: ./.cloudflared/tunnel.json
  5. Now you can finally run the tunnel with cloudflared tunnel --config ./.cloudflared/config.yml run --url http://localhost:8040 tunnel-name. Notice how you have to pass the config manually and not after run because otherwise it breaks. Cloudflared only searches ~/.cloudflared because everyone knows non reproducible user based global configs are the best