Node-red / nginx integration

I am running a node-red instance on my Pi and using Nginx to do revers proxy and https for me. It works well. My goal is to be able to default to the ui when you enter the domain on the browser. So far I have not figured out a way to do that. I have added the /ui to the revers proxy definitions in sites-enabled but when I go to the my domain I get an error saying that '/uiui' can not be found. I have tweaked settings.js and so far have not figured out a way to do it. For reference i used as a guide.

Does anyone have experience with this?

@meeki007 is often around so can probably help - but it looks like you have got the /ui part defined in too many places... either the proxy needs to point to /ui and node-red configured soo the ui is at / - or the proxy to / and the ui to /ui - you seem to have both.

Thank you for your reply... I have tried configs using /ui in the proxy config and not in the settings.js and vise versa. It's does seem to be a relative path issue.

Here is my proxy:

location / {

Here is my settings.js config:
// relative to httpRoot
ui: { path: "ui" },

httpRoot is commented out currently... at the moment if I dont put the path of /ui in the domain, I bring up the editor. /ui will bring up the dashboard. I was just trying to not have to put domain/ui in the url ..


thanks @dceejay for tagging me on this one. I've been so busy at work I only have time to check my email once a day.

Checking what I use on my server(s) to not use 'ui' in the url. Give me an hour for a answer.

Still working on this. Going step by step and spining up a server based on my guide so I can add a section for making the UI for the dashboard the default page that loads :slight_smile:

OK so I remember having a hell of a time doing what you want. Make the dashboard the main site.

Dug through my notes and found what I did. First thing node-red dashboard will not load at / , you have to give it something like /ui or /default or /mycreativenamehere. but if you try to load directly to that url with nginx it will not work because node-red dash board thinks that its base url is that. its not a static site!! it will not work.

but you can forward to it using node-red.

import this

[{"id":"bc18e1d4.45a","type":"comment","z":"ead71706.78a54","name":"Redirect any request to root ip IE: http://X.X.X.X to /ui/","info":"","x":260,"y":120,"wires":[]},{"id":"9422a6eb.474208","type":"http response","z":"ead71706.78a54","name":"","statusCode":"","headers":{},"x":570,"y":160,"wires":[]},{"id":"b088c465.1f775","type":"function","z":"ead71706.78a54","name":"headders, paylod and status code","func":"\n//msg.payload = (was already sent)\n\nmsg.statusCode = \"303\";\n\nmsg.headers = {};\nmsg.headers['X-Robots-Tag'] = \"noindex\";\nmsg.headers['Location'] = \"/ui/\";\nmsg.headers['no-fs-server'] = \"true\";\n\n\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":340,"y":160,"wires":[["9422a6eb.474208"]]},{"id":"871528d1.c6e48","type":"http in","z":"ead71706.78a54","name":"","url":"/","method":"get","upload":false,"swaggerDoc":"","x":110,"y":160,"wires":[["b088c465.1f775"]]}]

it will still show after it redirects but you can now goto the root url.

todo this you need to edit your settings.js file and enable the httpAdminRoot: '/admin', by removing the // in front of it.

httpAdminRoot: '/admin',

also I enable and edit the relative to httpRoot ui path to

ui: { path: "/ui" },

you can change the /ui to what ever you want but make sure you change the redirect to it as well.

I've got the test server I use spun up to test this all out fresh install off the howto guide i made. I'm sending you a msg with the login details if you want to play / break it and not yours first. It will stay up for your use until the next person needs it. Don't count on it always being there. Its been 2 months from the last guy I helped needed it. So it could be yours for a good while. note I make a export of all the nodes and save it to file if he ever wants his stuff :stuck_out_tongue: he was warned about its use :stuck_out_tongue:

note: don't know your skill level with servers but you can just type:

sudo systemctl restart nodered.service

after editing your settings.js file . you don't have to restart the server.

With the following settings I can access my Node-red dashboard directly:

Relevant extracts from the Node-red settings file:

        uiPort: process.env.PORT || 1880,
        uiHost: "",
        httpAdminRoot: '/28y8f2clua4',
        ui: { path: "/" },

The full Nginx file:

## for Node red 
server {

  location  / {
    proxy_pass http://localhost:1880;
    proxy_set_header X-Real-IP $remote_addr;

    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";

    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

server {
    if ($host = {
        return 301 https://$host$request_uri;
    } # managed by Certbot

 listen 80;
   return 404; # managed by Certbot

} will direct to the Node-red dashboard and will direct to the Node red editor.

28y8f2clua4 is just a random string that makes it a little bit more difficult to access the editor (which is of course also protected by a password) without knowing the exact url.

It would, I suppose, be possible to do the same without ssl. (NOT recommended!)

1 Like

Gentlemen, thanks for your replies. I will give this a go today. I did stumble upon moving the editor to admin (by luck). Nice to see that you guys confirmed that at least. I will report back later today.


Good news... I got it working. I did not need to use the flow that was provided by meeki007. Peter's set up works fine. I had to wrestle with the configs as I am using node-red-contrib-users for jwt authentication. Thanks so much for the help. meeki007 I could not have done this with out the outstanding guide you have posted..

regards, Mick

1 Like

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.