Help with controlling access to multiple instances of node-red

906 views
Skip to first unread message

Matt Hildom

unread,
Mar 19, 2017, 1:47:42 PM3/19/17
to Node-RED
So I have tried looking into this and as far as I've understood, in order to have multiple dashboards you would need multiple instances of Node-Red running on their own ports. I found a discussion on here about someones work with running multiple instances of Node-Red using pwm2.

Then end goal is to have a main webpage (which is its own dashboard) which gives the user some sort of information, but then can redirect them to their dashboard by clicking a button. In the end there would be an instance of node-red running for each user, and as far as I can tell, each of those instances would require having their own unique port. So as far as I understand, for 3 users, their urls would look something like
Home Page: www.home.com
User 1: www.home.com:1880/ui
User 2: www.home.com:1881/ui
User 3: www.home.com:1882/ui

Im not sure if that is correct, but like I said that's what my understanding is for having  multiple instances of node-red.
Is there another way of doing this so that the users could get to their dashboard simply by doing:
www.home.com/user1

If not, which I don't think is possible, would it be possible to create buttons on the home dashboard that either redirect or open a new window to the users dashboard?
I know the users could simply enter their url, but I am trying to make it as simple as possible on their end without having to memorize a port number and so on.

If I am misunderstanding anything please let me know, I'm new to node-red and nodejs in general, thanks in advance

Mike Blackstock

unread,
Mar 19, 2017, 5:00:49 PM3/19/17
to Node-RED
Quick search on this group for 'multi user node red' should bring up some information about FRED, Redzilla and other similar requests and hints on how to implement something like this.
Our FRED service uses a proxy to authenticate and direct logged in users to different instances. http://sensetecnic.com/how-fred-cloud-node-red-works/

I've also proposed supporting multi-user dashboards on a single instance: https://groups.google.com/forum/#!topic/node-red/tBSFhklM1cY This is slightly different - you would have a single NR instance that gets information about the user who is interacting with the dashboard, can target different user's dashboards with data, or different groups of users.  Finally you can show different dashboard tabs based on a user's group.

I am working on cleaning this code up, along a simple flow and some documentation around how to get it up and running. Your feedback would be appreciated.

Mike

Julian Knight

unread,
Mar 19, 2017, 5:06:09 PM3/19/17
to Node-RED
A couple of things here.

Firstly you are correct that Dashboards are really only single user. Node-RED itself really only has limited multi-user features for now though longer term it may well change.

Secondly, you are right that each instance of Node-RED requires its own port. This follows the same pattern as for Node.js that Node-RED is built using. 

It is however possible to hide this using a reverse proxy should you need to. Using port numbers is not very user friendly as you've pointed out and there are lots of examples for node.js on using reverse proxies to handle multiple node.js apps or app instances. You can indeed map each instance to a "folder" like URL as you've indicated. You might also want to look at Phusion Passenger which started life as a way to efficiently run Python but rapidly evolved to be able to front all sorts of app engines such as node.js and Ruby. You should use something like NGINX to provide the reverse proxy.

Thirdly, I hope you aren't thinking of running this on a Raspberry Pi! ;-)

Finally, depending on your skills, are you sure you want to use Dashboard for this? It is great for quickly building a quick UI with no or limited HTML/JS skills but it isn't a magic bullet. Maybe think about writing your own interface either from within Node-RED or even using node.js/ExpressJS that would more easily lend itself to a multi-user environment. Leaving Node-RED to handle some business logic perhaps.

Mike Blackstock

unread,
Mar 19, 2017, 5:30:57 PM3/19/17
to node...@googlegroups.com
Julian has made some good points as usual!

A reverse proxy is at the heart of FRED and Redzilla as well.  I think that using multiple instances of node-red to implement multiple dashboards (one for each user) can be overkill in some cases (not to mention uses lots of RAM).

Either a custom web application on express and node-red, or something like a multi-user dashboard as I'm working on might be a good way forward depending on what you want to do, but it depends on your requirements.

Mike

--
http://nodered.org
 
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to a topic in the Google Groups "Node-RED" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/node-red/vT5f_dvDGdg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to node-red+unsubscribe@googlegroups.com.
To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.
To view this discussion on the web, visit https://groups.google.com/d/msgid/node-red/a6ba075b-75b6-4e39-ace9-711b9022cf0d%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Mike Blackstock
Chief Technical Officer
Sense Tecnic Systems, Inc.
308 East 5th Avenue, Vancouver, BC, V5T1H4
www.sensetecnic.com

Matt Hildom

unread,
Mar 19, 2017, 6:40:34 PM3/19/17
to Node-RED
Thanks for the feedback so far. The entire premise of this is to basically create a dedicated website/portal for users to connect to and check on their IoT devices, without them having to worrying about anything technical, so as simple as I can make it for them the better. Most of my experience in programming is in Java and C++, but if I'm understanding you right, it would be better to build the home page using nodejs? And I don't know much about nginx but I will definitely look into it and how to set up the reverse proxy. Thanks to both of you for your help!

Julian Knight

unread,
Mar 19, 2017, 8:51:33 PM3/19/17
to Node-RED
It may be best to make use of MQTT to keep track of the device statuses and create a user based front-end that picks up the appropriate device status for that user.

That could be done in NR or with pure node.js. The key is in reliably identifying a user and filtering the results accordingly. How you do that is going to depend on how you can associate a device with a user.

That could be done via the front or back-ends but probably safest via the back-end. Otherwise you have to allow access to your MQTT broker from the front end, with all the associated security issues.
Reply all
Reply to author
Forward
0 new messages