Node-RED

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.


Note

For this guide you should be familiar with the basic concepts of

Prerequisites

We’re using Node.js in the stable version 20:

[isabell@stardust ~]$ uberspace tools version use node 20
Using 'Node.js' version: '20'
Selected node version 20
The new configuration is adapted immediately. Patch updates will be applied automatically.
[eliza@dolittle ~]$

Your domain needs to be setup:

[isabell@stardust ~]$ uberspace web domain list
isabell.uber.space
[isabell@stardust ~]$

Installation

Use npm to install node-red globally.

[isabell@stardust ~]$ npm install -g --unsafe-perm node-red
[...]
+ node-red@1.3.3
added xx package in yys

Configuration

Setup daemon

Create ~/etc/services.d/node-red.ini with the following content:

[program:node-red]
command=node-red
autostart=yes

After creating the configuration, tell supervisord to refresh its configuration and start the service:

[isabell@stardust ~]$ supervisorctl reread
SERVICE: available
[isabell@stardust ~]$ supervisorctl update
SERVICE: added process group
[isabell@stardust ~]$ supervisorctl status
SERVICE                            RUNNING   pid 26020, uptime 0:03:14
[isabell@stardust ~]$

If it’s not in state RUNNING, check your configuration.

Configure web server

Note

Node-RED is running on port 1880. Additionally, the --remove-prefix parameter is needed if you want to run Node-RED under a sub URI like /nodered instead of the root URI /.

To make the application accessible from the outside, configure a web backend:

[isabell@stardust ~]$ uberspace web backend set / --http --port <port>
Set backend for / to port <port>; please make sure something is listening!
You can always check the status of your backend using "uberspace web backend list".
[isabell@stardust ~]$

Node-RED can now be accessed via https://isabell.uber.space/.

Securing

Note

By default, Node-RED is accessible by everyone without a password!

At least, an admin and editor password should be set as described in the Node-RED documentation (https://nodered.org/docs/user-guide/runtime/securing-node-red#editor–admin-api-security). The configuration file is located at ~/.node-red/settings.js.

After changing the configuration, restart Node-RED to reload configuration:

[isabell@stardust ~]$ supervisorctl restart node-red
node-red: stopped
node-red: started
[isabell@stardust ~]$ supervisorctl status
node-red                         RUNNING   pid 21665, uptime 0:00:22
[isabell@stardust ~]$

Updates

Use npm update Node-RED:

[isabell@stardust ~]$ npm update -g node-red
[...]
+ node-red@1.3.4
updated 7 packages in 29.546s

Then restart the service:

[isabell@stardust ~]$ supervisorctl restart node-red
node-red: stopped
node-red: started
[isabell@stardust ~]$ supervisorctl status
node-red                         RUNNING   pid 4711, uptime 0:00:42
[isabell@stardust ~]$

Tested with Node-RED 3.1.0, Uberspace 7.15.6

Written by: Sven <mail@klomp.eu>