Cloudflared docker on Synology

Hi All,

Removed all the lines, because my second post was solution. With good help of one person.
Below the steps how I let cloudflared work on my Synology NAS inside a docker.

source: https://developers.cloudflare.com/cloudflare-one/connections/connect-apps/install-and-setup/tunnel-guide

After some more search I found this way how to do it directly on my NAS:

sudo mkdir /volume1/docker/cloudflared
sudo chown 65532:65532 /volume1/docker/cloudflared/
sudo docker run -it --rm --name= cloudflared -v /volume1/docker/cloudflared/:/etc/cloudflared/ -v /volume1/docker/cloudflared/:/home/nonroot/.cloudflared/ cloudflare/cloudflared:2022.2.0 tunnel login
sudo docker run -it --rm --name= cloudflared -v /volume1/docker/cloudflared/:/etc/cloudflared/ -v /volume1/docker/cloudflared/:/home/nonroot/.cloudflared/ cloudflare/cloudflared:2022.2.0 tunnel create my-tunnel

Create a config.yaml file add some info:

sudo vi /volume1/docker/cloudflared/:/etc/cloudflared/config.yaml

Past below lines and add the correct filename and tunnel id:

credentials-file: /etc/cloudflared/<FILENAME OF CREATED JSON FILE>.json
tunnel: <ID OF TUNNEL>
ingress:

  - hostname: host1.example.com
    service: http://192.168.100.24:8123

  - hostname: host2.example.com
    service: https://192.168.100.62:7035
    originRequest:
      noTLSVerify: true
  
  - service: http_status:404
sudo docker run --name=cloudflared -v /volume1/docker/cloudflared/:/etc/cloudflared/ -v /volume1/docker/cloudflared/:/home/nonroot/.cloudflared/ cloudflare/cloudflared:2022.2.0 tunnel route dns my-tunnel my-awesome.example.com

I’m assuming you got most of it working (correct me if I am wrong).

To fix the config.yml file, just make sure the origin configuration is specified correctly. Specifically:

credentials-file: /etc/cloudflared/credentials.json
tunnel: 4d142040-<SECURE>-c8d272980010
ingress:

  - hostname: hostwork.example.com
    service: http://192.168.100.24:8123

  - hostname: hostnotwork.example.com
    service: https://192.168.100.62:7035
    originRequest:
      noTLSVerify: true
  
  - service: http_status:404

Just an an FYI, most of the commands you ran at the start can also be run on another machine and then you copy over the files, no need to do everything via the container. To note that most of the Docker stuff on Synology is pretty weird, so it’s very common to see issues.

2 Likes

I have updated my second post. Found a way to do it directly on my NAS.
Every time I learn more and found a way to do it easier!

Trying to do this myself and running into some snags, maybe you can clarify things. Any help would be appreciated.

When you change the folder ownership to 65532, is that a specific user on my system? Might it be different on my synology?

When trying to modify the config file, if I run the command as written:
sudo vi /volume1/docker/cloudflared/:/etc/cloudflared/config.yaml
VIM will say [New Directory] and then when I go to save, it tells me it can’t open the file for writing.

If I ignore the second part, and just run
sudo vi /volume1/docker/cloudflared/config.yaml

I can save the file - but then once I start the container, it is immediately stopping. Docker does not seem to have a log as to why.

1 Like

I’m having this exact same issue. Did you get it figured out?

When trying to modify the config file, if I run the command as written:
sudo vi /volume1/docker/cloudflared/:/etc/cloudflared/config.yaml
VIM will say [New Directory] and then when I go to save, it tells me it can’t open the file for writing.

If I ignore the second part, and just run
sudo vi /volume1/docker/cloudflared/config.yaml

Same issue for me. I created the config.yaml directly in /volume2/docker/cloudflared since doing it with the command listed, doesn’t work (my docker folder is on volume2 for my Synology), From what I can tell running the command as written in this post will always fail, because the container is not running yet at that point, it can’t write to a container that is not running. So creating it manually in the location its expected was my only option. My container will run for a second, then stop.

Hi @andrewjmoser, @danseals, @mjreagle,

Maybe you want to follow this guide to set up a CF tunnel on your Synology: