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
- Open the Cloudflare dashboard, search Tunnel
- Click Create a tunnel → choose Cloudflared → name it (e.g.
nas). - Copy the tunnel token shown in the Docker install command. You only need the token string.
Run Cloudflared in Docker
- Open Container Manager → Image → search cloudflare/cloudflared
- Go to Container → Create
- In the command, input the one copied from Cloudflare (tunnel --no-autoupdate run --token {token})
- Network select host
- Then start the container
Add subdomain
- Go to tunnel config, add route
- Service URL, if cloudflared is running in the NAS, then can use http://localhost:{service-port} or https://localhost:{service-port}
Set DNS
- Cloudflare dashboard search DNS
- Use CNAME
- Turn on Yellow Cloud
- Target should be a long xxxxxxxx.cfargotunnel.com
Comments ()