QNAP NAS中Docker容器Node.js应用公网访问配置求助
Got it, let's walk through this step by step— I’ve set up exactly this kind of QNAP + Docker + custom domain setup a handful of times, so I know the ropes. Here’s how to get your Node.js app accessible from the outside, both via your myqnapcloud domain and your custom domain:
1. First: Lock Down Port Forwarding & Firewall Rules
Since you have a static public IP, start here to let external traffic reach your NAS:
- Log into your home router’s admin panel (usually via something like
192.168.1.1). Find the Port Forwarding or Virtual Servers section. - Add two rules:
- Forward public port
80(HTTP) to your NAS’s local IP and port80 - Forward public port
443(HTTPS) to your NAS’s local IP and port443
- Forward public port
- Head to your QNAP’s Control Panel > Security > Firewall and add inbound rules to allow traffic on ports
80and443from any source (or restrict to specific IPs if you want extra security).
2. Configure Reverse Proxy in QNAP
QNAP has built-in reverse proxy tools that make mapping domains to your Docker app straightforward:
- Go to Control Panel > Network & File Services > Web Server > Reverse Proxy (some QNAP versions might have this under "Application Services").
- Add your first rule for the myqnapcloud domain:
- Source: Select
HTTPS(always prefer HTTPS over HTTP), entermy-server.myqnapcloud.comas the hostname, set port to443, and if you want a subpath like/my-app, enter that in the "Path" field. - Destination: Select
HTTP(unless your Node.js app uses HTTPS internally), enter your NAS’s local IP (orlocalhostif your container is on the same network), and input your<local-port>(the one you use to access the app locally). - Check the WebSocket box if your Node.js app uses real-time features (like chat or live updates)— this is easy to miss but critical for those use cases.
- Source: Select
- Save the rule. You can test this right away by accessing
https://my-server.myqnapcloud.com/my-appfrom a device not on your local WiFi.
3. Set Up Your Custom Domain
To map your own domain to the app:
- Go to your domain registrar’s website (where you bought your custom domain) and navigate to DNS settings.
- Add an A Record: Point your domain (e.g.,
my-domain.com) or subdomain (e.g.,my-app.my-domain.com) to your NAS’s static public IP. Note: DNS changes can take 10 minutes to a few hours to propagate. - Back in QNAP’s Reverse Proxy settings, add a second rule:
- Source: Again use
HTTPS, enter your custom domain/subdomain as the hostname, port443. - Destination: Same as before— NAS local IP and
<local-port>.
- Source: Again use
- (Critical) Get an SSL certificate for your custom domain: Go to Control Panel > Security > SSL Certificates, click Add > Let’s Encrypt, enter your custom domain, and follow the prompts. This removes the "unsecure" browser warning when accessing your app.
4. Double-Check Docker Container Settings
Make sure your Node.js container is configured to accept external traffic:
- Open Container Station, find your Node.js app, and go to Settings > Network.
- Confirm your port mapping is correct: The container’s internal port (e.g.,
3000, where your Node.js app is listening) should be mapped to your NAS’s<local-port>. - If you’re using QNAP’s default bridge network, ensure the container is reachable from the NAS (you can test this by pinging the container’s IP from the NAS’s terminal if needed).
5. Test Everything
- Use a mobile device on cellular data (not your home WiFi) to visit both
https://my-server.myqnapcloud.com/my-appand your custom domain once DNS propagates. - If you run into issues, check:
- Router port forwarding rules are active
- QNAP firewall isn’t blocking traffic
- Reverse proxy rules have the correct ports and hostnames
- Your Node.js app is running and listening on the correct internal port
内容的提问来源于stack exchange,提问作者Łukasz Ostrowski




