aeleos / cloudflared

Cloudflare Tunnel Instructions and Template for Unraid
173 stars 21 forks source link

Unabel to create tunnel #12

Closed Kirizan closed 3 years ago

Kirizan commented 3 years ago

When following the guide to create the tunnel I run the command:

docker run -it --rm -v /mnt/user/appdata/cloudflared:/home/nonroot/.cloudflared/ cloudflare/cloudflared tunnel home

However there is no UUID assigned. The output from the above command is:

INFO[2021-07-17T19:56:06Z] Writing tunnel credentials to /home/nonroot/.cloudflared/.json. cloudflared chose this file based on where your origin certificate was found.
INFO[2021-07-17T19:56:06Z] Keep this file secret. To revoke these credentials, delete the tunnel.
INFO[2021-07-17T19:56:06Z] Created tunnel  with id 

The command docker run -it --rm -v /mnt/user/appdata/cloudflared:/home/nonroot/.cloudflared/ cloudflare/cloudflared tunnel login was successful, and shows active when I browse to the linked site. The cert.pem file exists in the cloudflared directory.

The file /.json contains an AccountTag and TunnelSecret entry. If I use the AccountTag as the UUID in the config.yaml and point to the /.json file, then the Unraid container logs show:

couldn't read tunnel credentials from /home/nonroot/.cloudflared/0bef133257fea08ceaac39a8ad77d303.json: open /home/nonroot/.cloudflared/0bef133257fea08ceaac39a8ad77d303.json: no such file or directory
couldn't read tunnel credentials from /home/nonroot/.cloudflared/0bef133257fea08ceaac39a8ad77d303.json: open /home/nonroot/.cloudflared/0bef133257fea08ceaac39a8ad77d303.json: no such file or directory

If I try to list the tunnels (to get the UUID there), I get the error:

Error listing tunnels: failed to decode response: json: cannot unmarshal object into Go value of type []tunnelstore.Tunnel

If I try to rename the /.json file to AccountTag.json (replacing with the actual value from the account tag, and updateding the config.yaml), then the Unraid container logs show:

2021-07-17T20:11:15Z ERR Register tunnel error from server side error="Unauthorized: Record for tunnel not found" connIndex=0

If I try to create other tunnels, it's the same. I can't find any tunnel list from within the CloudFlare to try to find the correct UUID. Have you see anything like this, or how to fix it?

biggator commented 3 years ago

Unfortunately, Cloudflare does not properly tag their docker images with latest. You've likely pulled an old version of cloudflared (like I did). Visit this page and copy the pull command of the most recent image (you'll see a docker pull command on the right side). For example, I used:

docker pull cloudflare/cloudflared:2021.7.0-amd64

This pulls the latest image. You can either reference those tags in the commands or use the following commands to remove the old one and tag the new one as latest.

docker rmi cloudflare/cloudflared:latest
docker tag cloudflare/cloudflared:2021.7.0-amd64 cloudflare/cloudflared:latest

Then you may need to remove the faulty tunnel before recreating it (replace TUNNELNAME):

docker run -it --rm -v /mnt/user/appdata/cloudflared:/home/nonroot/.cloudflared/ cloudflare/cloudflared tunnel delete TUNNELNAME
Kirizan commented 3 years ago

This did it, now everything is working as expected. Thank you very much!