X

Break New Ground

Installing Node-RED In An Always Free VM On Oracle Cloud

Last month at Oracle Open World we announced a very exciting "always free" tier for Oracle Cloud. I recently blogged about how you could use an "always free" VM to run a Minecraft server, and I thought that it would be good to do an ongoing series of posts that highlight some different projects that our "always free" VMs and Autonomous DB instances can be used for. In today's edition, we'll take a look at installing Node-RED.

Here's an outline of the sections below, feel free to skip ahead if you're already familiar with a specific step:

Let's get into it!

Free Cloud Sign Up

Before we get started, you'll have to sign up for a free account with Oracle Cloud. Sign up requires a credit card, but there are absolutely no charges at all if you follow the tutorial below.

If you're not yet the age of majority (usually 18), please have your parent sign up for a free Oracle Cloud account and help you with the steps below!

After you have created your free account and signed in, the first thing you'll need to do is create a virtual machine that will be used to host the Minecraft server.

What Is Node-RED?

If you're not familiar with Node-RED, their website describes the project as:

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.

Here's a quick intro video to help you understand what it is and how it 

As you can see, it's a pretty powerful and fun application to play around with. Let's create a VM that we can use to install it! 

Creating An Always Free VM

Log in to your Oracle Cloud account and head to the console. From the dashboard, select 'Create a VM Instance' to get started.

Next, enter a name for your instance and make sure that the Image Source is Oracle Linux 7.7.

Make sure that the Availability Domain, Instance Type and Instance Shape are all "Always Free Eligible".

Now scroll down and upload a public SSH key that you can use later on to SSH in to the VM once it is running.

Scroll down and make sure that "Assign a public IP address" is selected.

Click 'Create' and you'll be taken to the instance details where the VM will be in a "Provisioning" state.

When the VM becomes "Active" you'll have a public IP address assigned. Copy this and keep it handy for later.

Modifying Your Security List

On the instance details page, click on your assigned subnet.

In the left hand sidebar on the subnet details page, click on "Security Lists":

Then click on the default security list to edit it:

Add an ingress rule for port 1880, the port used by Node-RED:

SSH Into Your VM

From a terminal window on your local machine, make an SSH connection into your VM using the private key associated with the public key you specified at instance creation and the IP address of your VM. Use opc as the username:

Installing Node-RED

There are a number of tutorials for installing Node-RED, but the one we'll use is the "manual install" method (just ignore any references to Raspberry Pi in this script). To run this script, first evaluate it on GitHub and then run:

bash <(curl -sL https://raw.githubusercontent.com/node-red/linux-installers/master/rpm/update-nodejs-and-nodered)

Note: This script will install Node.JS, Node-RED and optionally add a firewall rule that adds port 1880 to the public zone. Answer "y" to allow this firewall rule to be created when it asks you.

Once it is complete you will see output similar to this:

Start Node-RED with node-red-startand you will see output similar to the following:

You can ensure that Node-RED always starts at boot with:

sudo systemctl enable nodered.service

You're now ready to launch Node-RED in your browser at http://[public-IP]:1880

You're now ready to start creating and deploying flows in your "always free" VM on the Oracle Cloud.  You can create your own flow from scratch or import a flow from the Node-RED Library. What great ideas do you have for Node-RED in your "always free" VM? Leave them in the comments below!

Securing Node-RED

Now that you're up and running, you'll need to secure your Node-RED install in a few ways. You should check out the Node-RED docs to learn how to properly secure your install with a username and password. Also, you'll want to use a SSL/TLS cert for HTTPS transport and encryption which is easy to configure in the Oracle Cloud.

Photo by Samuel Ferrara on Unsplash

Join the discussion

Comments ( 8 )
  • Greg Stephens Friday, October 18, 2019
    Thanks for the tutorial. I'm trying out Oracle Cloud for the first time and using Node-Red. Everything works but port 1880 is still blocked. lsof shows the node-red listening on the port. I've created the ingress rule as shown. Any suggestions on where to look?
  • Greg Stephens Friday, October 18, 2019
    I had to issue the following commands:

    sudo firewall-cmd --permanent --zone=public --add-port=1880/tcp
    sudo firewall-cmd --reload
  • Paul Friday, October 18, 2019
    Hi Todd, thanks for a great tutorial, I've followed it, but wondered if you could expand upon the 'SSH into your VM' section please.
    I have PuTTY installed on a Windows laptop, and the private key installed in a Raspberry Pi in the folder /home/pi/.ssh/ but when I try 'ssh opc@140.238.70.40 -i ~/.ssh/oracle_private_key.txt' I get a error 'Unable to open connection - host does not exist'.
  • Todd Sharp Friday, October 18, 2019
    @Paul:

    I'm not sure how the Raspberry Pi comes into the picture. Are you trying to SSH from your Windows machine to the Oracle Cloud instance, or from a Raspberry Pi?
  • Todd Sharp Friday, October 18, 2019
    @Greg: That's odd, the install script should have done that for you. Did you have any errors during the install?
  • Paul Friday, October 18, 2019
    Sorry (embarrassing!!), yes I'm trying to SSH from Windows, but have no idea where & how to store the certificate in Windows 10, to be able to authenticate SSH via PuTTY.
    Also, should I be able to ping the instance public IP address (140.238.70.40) because it's not responding, despite Oracle telling me that it's running and a green status.
  • Paul Friday, October 18, 2019
    Hi Todd, please ignore or delete my posts above, I've has some kind help from the node-RED forum guys, who have educated me in using Windows (ugh).

    Your tutorial has worked perfectly, and I now have node-RED happily running in the VM.

    Could I suggest though, that you add a paragraph stressing the importance of securing node-RED at the earliest opportunity. Maybe a link to https://nodered.org/docs/user-guide/runtime/securing-node-red would suffice.
  • Todd Sharp Monday, October 21, 2019
    @Paul:

    Glad you have got it working!

    > Could I suggest though, that you add a paragraph stressing the importance of securing node-RED at the earliest opportunity

    Great point. I've added that to the article!
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.