如何在 VPS 上自托管 Node-RED:2026年完整指南
使用 Docker 在您自己的 VPS 上部署 Node-RED。涵盖安装、认证、SSL 设置和优化的分步指南。
Why Self-Host Node-RED?
Node-RED is a flow-based programming tool originally built by IBM for wiring together IoT devices, APIs, and online services. With a drag-and-drop visual editor running in the browser, it's one of the easiest ways to build automations without writing much code. The current stable version is 4.1.x, with Node-RED 5.0 on the horizon bringing a modernized UI and built-in dark theme.
Self-hosting Node-RED on a VPS gives you 24/7 uptime, full control over your data, and the ability to install any community node package. Unlike cloud-hosted alternatives, there are no per-flow limits or execution caps.
What You'll Need
Before we start, make sure you have:
- A VPS with at least 1 GB RAM and 1 vCPU (we recommend Hostinger VPS starting at $6.49/mo or DigitalOcean starting at $6/mo)
- A domain name pointed to your VPS IP address
- Basic familiarity with Linux command line
- SSH access to your server
Node-RED is extremely lightweight — it runs on Raspberry Pi hardware — so even the smallest VPS plan will work for most use cases. For production with many flows and add-on nodes, 2 GB RAM is recommended.
Step 1: Prepare Your VPS
Connect to your VPS via SSH and update the system:
ssh root@your-server-ip
apt update && apt upgrade -y
Step 2: Install Docker and Docker Compose
curl -fsSL https://get.docker.com -o get-docker.sh
sh get-docker.sh
apt install docker-compose-plugin -y
Verify the installation:
docker --version
docker compose version
Step 3: Create the Docker Compose File
Create a directory for Node-RED:
mkdir -p /opt/nodered && cd /opt/nodered
Create the docker-compose.yml file:
version: "3.7"
services:
node-red:
image: nodered/node-red:latest
restart: always
environment:
- TZ=UTC
ports:
- "1880:1880"
volumes:
- node-red-data:/data
volumes:
node-red-data:
Node-RED runs on port 1880 by default and stores all flow data, credentials, and settings in the /data directory inside the container.
Step 4: Start Node-RED
docker compose up -d
Your Node-RED instance is now running. Access it at http://your-server-ip:1880.
Step 5: Enable Authentication
By default, Node-RED has no authentication — anyone with the URL can access your editor. This is critical to fix before exposing it to the internet.
Generate a password hash:
docker exec -it $(docker ps -q -f name=node-red) npx node-red-admin hash-pw
Enter your desired password when prompted. Copy the hash output.
Now create a custom settings file. First, copy the default settings out of the container:
docker cp $(docker ps -q -f name=node-red):/data/settings.js ./settings.js
Edit settings.js and uncomment/add the adminAuth section:
adminAuth: {
type: "credentials",
users: [{
username: "admin",
password: "$2b$08$YOUR_HASH_HERE",
permissions: "*"
}]
},
Update your docker-compose.yml to mount the custom settings file:
volumes:
- node-red-data:/data
- ./settings.js:/data/settings.js
Restart Node-RED:
docker compose restart
Step 6: Set Up SSL with Nginx
For production, set up a reverse proxy with SSL. Install Nginx and Certbot:
apt install nginx certbot python3-certbot-nginx -y
Create an Nginx configuration at /etc/nginx/sites-available/nodered:
server {
listen 80;
server_name nodered.yourdomain.com;
location / {
proxy_pass http://localhost:1880;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
Important: The Upgrade and Connection headers are required because Node-RED's editor uses WebSockets.
Enable the site and get an SSL certificate:
ln -s /etc/nginx/sites-available/nodered /etc/nginx/sites-enabled/
nginx -t && systemctl reload nginx
certbot --nginx -d nodered.yourdomain.com
After SSL is configured, update your docker-compose.yml to only listen on localhost:
ports:
- "127.0.0.1:1880:1880"
Optimization Tips
- Install community nodes — Node-RED has thousands of community-contributed node packages. Install them directly from the editor's palette manager or via
npm installin the data volume. - Enable Projects — Set the
NODE_RED_ENABLE_PROJECTS=trueenvironment variable to enable Git-based flow versioning. - Set up backups — Use cron to periodically back up the Docker volume:
docker run --rm -v node-red-data:/data -v /backups:/backup alpine tar czf /backup/nodered-$(date +%Y%m%d).tar.gz /data - Monitor resources — Use
htopordocker statsto watch CPU and memory usage. - Keep it updated — Pull the latest image regularly:
docker compose pull && docker compose up -d
Which VPS Should You Choose?
Based on our testing, here are our top recommendations for hosting Node-RED:
- Hostinger VPS — Best overall value. KVM 1 plan ($6.49/mo) gives you 4 GB RAM, more than enough for Node-RED with dozens of flows.
- DigitalOcean — Best documentation and one-click apps. The $6/mo Basic plan works well for light usage.
- Contabo — Most resources for the price. 4 vCPU and 8 GB RAM at $4.50/mo is perfect if you want to run Node-RED alongside other tools.
Conclusion
Node-RED is one of the easiest automation tools to self-host thanks to its minimal resource requirements and excellent Docker support. For as little as $5/month, you can have a fully functional Node-RED instance running 24/7 with unlimited flows.
Get started today with one of our recommended VPS providers. In under 15 minutes, you'll have Node-RED running and ready to automate.
准备好开始自动化了吗?立即获取VPS。
立即开始使用 Hostinger VPS 主机。特惠价格可用。
* 联盟链接 — 我们可能会获得佣金,不会增加您的费用