0

When i want to access to Node Red via Brower I typ 192.168.0.24:1880/ui/. Now i just want to reach the Node-Red side have an local Domain something like website.test.

I already have changed my port form 1880 Port to 80.

Also i edit the /etc/hosts file to -> 192.168.0.24 website.test But when I test it, I cant access to the Node-Red Website with this Domain.

Does anyone know how to accomplish this?

3
  • Where are you trying to access the editor from? Which machine did you edit /etc/hosts on? Also which user are you running Node-RED as?
    – hardillb
    Feb 26, 2021 at 8:17
  • I set Node-Red on Raspi, which is in the same Network with my pc. When I want to access to my created Node-Red Website with my Pc i type 192.168.0.24:1880/ui/ so I can see my website. Now I want to open it via a custom Domain from any other device in the same network. Like i already can do it with the ip. In /etc/hosts i just edit the IP, with which i can access the wanted Webseite next to the Domain i want. I didn´t know which user im running on Node Red but i can take a look
    – Baxw25
    Feb 26, 2021 at 8:54
  • could you please bind 127.0.0.1 website.test in /etc/hosts ?
    – Abilogos
    Feb 27, 2021 at 7:30

1 Answer 1

0

First, to bind Node-RED to port 80 will require you to run it as root on the pi. This is a VERY BAD idea unless you 100% understand the consequences as it opens up a LOT of potential security issues.

A better solution is to change the address that Node-RED binds to to be 127.0.0.1 so it only listens on localhost then use something like nginx to proxy it on to port 80.

You can change the bind address by uncommenting the uiHost line at the top of the settings.js file in the userDir (which is normally /home/pi/.node-red)

A basic nginx config would look like this:

server {
        listen 80;
        listen [::]:80;

        location / {
            proxy_pass http://127.0.0.1:1880;

        #Defines the HTTP protocol version for proxying
        #by default it it set to 1.0.
        #For Websockets and keepalive connections you need to use the version 1.1    
        proxy_http_version  1.1;

        #Sets conditions under which the response will not be taken from a cache.
        proxy_cache_bypass  $http_upgrade;

        #These header fields are required if your application is using Websockets
        proxy_set_header Upgrade $http_upgrade;

        #These header fields are required if your application is using Websockets    
        proxy_set_header Connection "upgrade";

        #The $host variable in the following order of precedence contains:
        #hostname from the request line, or hostname from the Host request header field
        #or the server name matching a request.    
        proxy_set_header Host $host;

        }
}

Second, editing the /etc/hosts file on the pi will only map a hostname for processes running on the pi not anywhere where (e.g. on your pc).

If your other machine is another Linux machine or a Mac then you can probably use mDNS to access the pi which by default will be found on raspberrypi.local. Unfortunately Windows doesn't support mDNS so that won't work (You may be able to add support by installing some printer packages from Apple).

You can edit the hosts file on Windows (C:\Windows\System32\drivers\etc\hosts) but this isn't a great solution as you will need to do it to every machine that wants to access the Node-RED instance.

Other options include adding an entry on your local router or running your own DNS server, but both of those options are far too complicated to get into here.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.