Expose NAS Services with Cloudflare Tunnel (Docker)

Expose NAS Services with Cloudflare Tunnel (Docker)

A Cloudflare Tunnel lets you publish self-hosted services (home.miawy.com, git.miawy.com, etc.) without opening router ports or exposing your home IP. Here are the main steps.

Prerequisites

  • A domain managed by Cloudflare DNS (here: miawy.com)
  • A NAS with Docker / Docker Compose (Synology Container Manager works)
  • Services already running on your NAS (e.g. Gitea on port 3000, a dashboard on port 8080)

Create the tunnel

  1. Open the Cloudflare dashboard, search Tunnel
  2. Click Create a tunnel → choose Cloudflared → name it (e.g. nas).
  3. Copy the tunnel token shown in the Docker install command. You only need the token string.

Run Cloudflared in Docker

  1. Open Container Manager → Image → search cloudflare/cloudflared
  2. Go to Container → Create
  3. In the command, input the one copied from Cloudflare (tunnel --no-autoupdate run --token {token})
  4. Network select host
  5. Then start the container

Add subdomain

  1. Go to tunnel config, add route
  2. Service URL, if cloudflared is running in the NAS, then can use http://localhost:{service-port} or https://localhost:{service-port}

Set DNS

  1. Cloudflare dashboard search DNS
  2. Use CNAME
  3. Turn on Yellow Cloud
  4. Target should be a long xxxxxxxx.cfargotunnel.com