Deploying a node red application online sometimes tend to be a tedious task, some people like to use a Raspberry Pi as a server but others don't count with one, that's why in this project we are going to learn how to host a Node Red app on a Digital Ocean server.
Important Note: You can use any cloud service (AWS, Microsoft Azure, Google Cloud, etc.), the set up process is similar.
Tools- Computer with Internet.
- Digital Ocean Account
- PuTTy
According to the official documentation Node Red is a programming tool for wiring together hardware devices, APIs and online services in new and interesting ways.It provides a browser-based editor that makes it easy to wire together flows using the wide range of nodes in the palette that can be deployed to its runtime in a single-click [1]. It is possible to work locally on Node Red, you can send data via serial communication or fetch the information from a data base, but theres only one user that will see the application, if you want to share it with friends, workmates or even clients you have to run Node Red on a server.
Digital OceanDigitalOcean is an american cloud infrastructure provider headquartered in New York City with data centers worldwide. DigitalOcean provides developers cloud services that help to deploy and scale applications that run simultaneously on multiple computers. As of January 2018, DigitalOcean was the third-largest hosting company in the world in terms of web-facing computers [2]. To deploy a node red application we are going to create an Ubuntu virtual machine on a droplet, using puTTy and via SSH we will access it.
ProcedureStep 1: Create an Ubuntu virtual machine and access itFirst we have to create an account on Digital Ocean: https://www.digitalocean.com/
To create a Ubuntu virtual machine we need to create a droplet, to do this we simply click on "Droplets" and then "Create Droplet".
In this case we are going to install Node Red on a Ubuntu virtual machine, but you could choose any OS.
About size and CPU numbers we are going to select 1GB of memory and 1vCPU because this is only an example project (for most projects this is more than enough)
Finally we just pick the closest data center and choose a Host Name.
We will be redirected to a page where we will see our droplet, to access it, we will received the droplet name, IP Address, Username and Password to our email.
Once we received the information we will insert it into puTTy and access the port 22 via SSH.
We just accept security alert and we will access the virtual machine via the command prompt.
Once we are inside the virtual machine we just login as root, paste the password that we received earlier and then change it.
Now we have a full Ubuntu virtual machine where we can execute Python, Node JS, etc. But we will use it to run Node Red.
Step 2: Install Node-RedFor a better understanding of the installation of Node Red on a Digital Ocean server I suggest you to visit Brian Boucheron post on the Digital Ocean forum, I will add the link on the sources list.
The only thing that I will add to Brian´s guide is to first execute the command:
$ sudo apt-get update
$ sudo apt-get upgrade
Now here is the following commands that Brian used:
$ sudo apt-get install nodejs
$ node -v
$ sudo apt-get install npm
$ npm -v
$ sudo npm install -g --unsafe-perm node-red node-red-admin
$ sudo ufw allow 1880
Step 3: Run Node-RedAnd now for opening Node Red we just simply execute the command:
$ node-red
To access Node Red dashboard we just put the IP address and the 1880 port (e.g 165.227.56.248:1880). Final result:
Now we can share our projects, this is a powerful tool because instead of building a full web app from scratch we can use Node Red for quick prototyping.
Sources
Comments
Please log in or sign up to comment.