Ricky Lin
Monday, September 25, 2023
Cloudflare tunnel on Synology
Setup Synology
- Create a directory in docker directory, such as
cloudflare-tunnel
. - Download cloudflared/cloudflared image to registry.
- ssh to admin@synology
- Change
cloudflare-tunnel
owner, sudo chown -R 65532:65532 /volume1/docker/cloudflare-tunnel
.
Run containers
- cloudflared tunnel login
- Run container and mount volume
docker/cloudflare-tunnel:/home/nonroot/.cloudflared
. - Select
Use the same network as Docker Host
in network tab. - Add command
tunnel login
in envorinment tab. - Go to container log, and copy login url.
- Paste url to browser and authorize the zone.
- Export the container setting json to the directory
cloudflare-tunnel
.
- cloudflared tunnel create synology-tunnel
- Edit the container setting json in the the directory
cloudflare-tunnel
, modify cmd. tunnel create synology-tunnel
. - Import the container setting json and run a new container.
- The container will stop and create tunnel config json in
cloudflare-tunnel
. - Create config.yml and write ingress rules.
- In config.yml, tunnel value is the same as the tunnel config json name, and credentials-file is
/home/nonroot/.cloudflared/tunnel config json
- Export the second container setting json to the directory
cloudflare-tunnel
.
- cloudflared tunnel route dns synology-tunnel synology.ruru910.com
- Edit the second container setting json in the the directory
cloudflare-tunnel
, modify cmd. tunnel route dns synology-tunnel synology.ruru910.com
. - Import the second container setting json and run a new container.
- The container will stop and create a dns record mapping domain to the tunnel.
- cloudflared tunnel run synology-tunnel
- Edit the second container setting json in the the directory
cloudflare-tunnel
, modify cmd. tunnel run synology-tunnel
. - Import the second container setting json and run a new container.
- The tunnel now is connectable.
Reference