Skip to content

The Ultimate Guide to Deploying Scalable Node-RED in the Cloud

Node-Red in Cloud

Table of Contents

🧾 Abstract

Node-RED is a powerful tool for wiring together hardware devices, APIs, and online services. While running it locally on a Raspberry Pi is great for prototyping, deploying it to the cloud ensures 24/7 availability and scalability. In this guide, you will learn how to deploy a production-ready Node-RED instance on a DigitalOcean Droplet, secured with Nginx as a reverse proxy, managed by PM2, and mapped to your custom domain nodered.arunkumarn.in using Cloudflare.


πŸ“š Prerequisites

Before starting, you should have:

  • Basic knowledge of the Linux Command Line.
  • SSH access to a remote server.

βœ… Supported OS

Platform Supported
Ubuntu 22.04 / 24.04 LTS βœ… Yes (Recommended)
Debian 11/12 βœ… Yes
CentOS/RHEL βœ… Yes

πŸ’° Exclusive Offer: Get $200 Free Credit

Ready to deploy? Use the link below to create your DigitalOcean account and receive $200 in free credit to experiment with Node-RED and other cloud services.

πŸ’°
Limited Time Offer
Enrol using the link to get $200 DigitalOcean credit
Click here for $200 Credit β†’

πŸ—οΈ Architecture Overview

For a scalable and secure deployment, we use the following stack:

  1. DigitalOcean Droplet: The virtual private server (VPS) hosting our environment.
  2. Node-RED: The core low-code engine.
  3. PM2: A process manager to ensure Node-RED restarts automatically if it crashes or the server reboots.
  4. Nginx: Acts as a reverse proxy to handle SSL and forward traffic to Node-RED.
  5. Cloudflare: Manages DNS records and provides an extra layer of security.

πŸ› οΈ Step-by-Step Setup Instructions

βœ… Step 1: Create a DigitalOcean Droplet

  • Sign in to your DigitalOcean account.
  • Click Create (top right) and select Droplets. DigitalOcean
  • Choose Region: Select the data center closest to you (e.g., Bangalore, NYC, or London). DigitalOcean
  • Choose Image: Select Ubuntu 24.04 LTS.
  • Choose Size: Select the Basic plan. For Node-RED, the $4/month or $6/month (Regular SSD) is more than enough. DigitalOcean
  • Authentication: Choose SSH Keys (Recommended for security) or Password.
  • Finalize and click Create Droplet. DigitalOcean

Once created, copy the IP Address of your new Droplet. DigitalOcean

βœ… Step 2: Login to the Droplet

  • SSH into your server:
ssh root@your_droplet_ip
  • Update the system:
sudo apt update && sudo apt upgrade -y

βœ… Step 3: Install Node.js and Node-RED

  • Node-RED requires Node.js. Install the LTS version:
# Download and install nvm:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.4/install.sh | bash

# restarting the shell
\. "$HOME/.nvm/nvm.sh"

# Download and install Node.js:
nvm install 24

# Verify the Node.js version:
node -v # Should print "v24.14.0".

# Verify npm version:
npm -v # Should print "11.9.0".
  • Now, install Node-RED globally:
sudo npm install -g --unsafe-perm node-red

βœ… Step 4: Setup PM2 Process Manager

To keep Node-RED running in the background:

sudo npm install -g pm2
pm2 start /usr/bin/node-red -- -v
pm2 save
pm2 startup

βœ… Step 5: Configure Nginx Reverse Proxy

  • Install Nginx:
sudo apt install nginx -y
  • Create a configuration file for your domain:
sudo nano /etc/nginx/sites-available/nodered.arunkumarn.in
  • Paste the following configuration:
server {
    listen 80;
    server_name nodered.arunkumarn.in;

    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;
    }
}
  • Enable the site and restart Nginx:
sudo ln -s /etc/nginx/sites-available/nodered.arunkumarn.in /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl restart nginx

Note

replace the domain name nodered.arunkumarn.in with your custom domain name.


🌐 DNS Configuration

  1. Login to your DNS server
    • Here Cloudflare is used.
  2. Select your domain arunkumarn.in.
  3. Go to DNS Settings > Add Record.
  4. Type: A, Name: nodered, Content: Your_Droplet_IP.
  5. Ensure the Proxy Status is set to "Proxied" (Orange cloud) for automatic SSL handling.

dns config


πŸ”’ Install SSL Certificate

We will use Certbot to get a free SSL certificate from Let's Encrypt.

  1. Install Certbot:

    sudo apt install certbot python3-certbot-nginx -y
    
  2. Run Certbot:

    sudo certbot --nginx -d nodered.arunkumarn.in
    

    Follow the prompts: Enter your email and agree to the terms. Certbot will automatically update your Nginx file to use SSL.

  3. Verify Auto-Renewal:

    sudo certbot renew --dry-run
    

πŸ›‘ Security Hardening

By default, Node-RED is open. You must enable authentication:

  1. Generate a password hash:
    node-red-admin hash-pw
    
  2. Edit the settings file:
    nano ~/.node-red/settings.js
    
  3. Find the adminAuth section, uncomment it, and replace the password hash with yours.
  4. Restart Node-RED: pm2 restart node-red.

πŸš€ Advanced Tips

  • Continuous Backups: Use GitHub to version control your flows.json.
  • Environment Variables: Store sensitive API keys in a .env file instead of hardcoding them in nodes.
  • Monitoring: Use the pm2 monit command to watch CPU and memory usage in real-time.

πŸ“Œ References


🏁 Conclusion

You now have a production-grade Node-RED instance running at your custom domainπŸŽ‰. With PM2 managing the process and Nginx handling the traffic, your IoT automation flows are ready to scale with high availability. Happy wiring!