Node-red dashboard or ui as web page

Hi

I want to access node-red dashboard as web page through apache2 web server installed in the same device with node red. could you help me with any link or document to access dashboard as web page?! does it need only to change ui port from 1883 to port 80, or there are more steps?!
Solution should be without a real Internet access . I need it for only experiment and testing.

thanks in advance

1 Like

Yo can add a reverse proxy directive to your apache configuration.
But you also have to take care of the web sockets connections.
Change the localhost path for your needs

Here an example config

<VirtualHost *:80>
  ServerName yourdomainname.com
<Location />
        AuthType Basic
        AuthName "Not4U"
        AuthBasicProvider file
        AuthUserFile "/etc/apache2/htpasswd-node"
        Require user jaxn
</Location>
  RewriteEngine On
  RewriteCond %{HTTP:Upgrade} =websocket [NC]
  RewriteRule /(.*)           ws://localhost:1880/$1 [P,L]
  ProxyPreserveHost On
  ProxyRequests Off
  ProxyPass / http://localhost:1880/
  ProxyPassReverse / http://localhost:1880/
</VirtualHost>

You can skip the <location> part as it is only for authentication. Maybe you need to add some additional modules. apache should tell you after a restart.

1 Like

Thanks,

could you give me a link or documentation for more details and to understand it very well?

if you google "reverse proxy apache" you should find enough information for your task

2 Likes

Not really read it in detail, but this looks reasonable:

It doesn't work with me
when I open it locally, 127.0.0.1:80
it appears 127.0.01/ui/ in the browser and only display in the page:

cannot GET /uiui/

could you help me to figure the prblem?

You can't so easily proxy 127.0.0.1 (AKA localhost) as it is a special loopback endpoint. You need to test it from a different device.

I did a mistake in configuration because that it showed that message, I fixed it however it still has a problem, and now the page is empty when I open it from another device in the same network.
Nothing it display in the page

You will need to compare your browser request with your web server's logs to see what it is doing. That you get an empty document rather than an error shows that the server has some understanding of the request but that the fulfilment isn't working as expected.

I found this in web-server error logs

[proxy error] [ pid...] (111) connection refused :AH00957: HTTP: attempt to connect to 127.0.0.1:1880 (127.0.0.1) failed

[proxy_http error] : AH01114: HTTP: failed to make connection to backend: 127.0.0.1

When I performed netstat -na
I found
0.0.0.0:1880 LISTEN
127.0.0.1:1880 Established

I don't know if this make sense,
I tried everything I found it in the internet, but I cant figure out what is the problem, or maybe I missed thing

Could you help me to figure the problem?
when I started node-red ...and I opened it in the same local device using 127.0.0.1:1880 or 0.0.0.0:1880, it works. but I noticed that only the port 0.0.0.0:1880 is in Listen mode when I do netstat...
and in my proxy configuration, I tried both 127.0.0.1, the webpage from another device is blank ..

I tried to change the host in node-red settings, and enable 127.0.0.1. in this case the netstat command shows 127.0.0.1:1880 is in listen mode. but the webpage is not working.

I cannot figure where the problem exactly?

I found this in web-server error logs

[proxy error] [ pid...] (111) connection refused :AH00957: HTTP: attempt to connect to 127.0.0.1:1880 (127.0.0.1) failed

[proxy_http error] : AH01114: HTTP: failed to make connection to backend: 127.0.0.1

When I performed netstat -na
I found
0.0.0.0:1880 LISTEN
127.0.0.1:1880 Established

I don't know if this make sense,
I tried everything I found it in the internet, but I cant figure out what is the problem, or maybe I missed thing

could you tell me what do you mean "take care of the web sockets connections.",?
I need it connect only on http traffic , not websocket.
further, could you help me in finding solution in my problem?

the Node-RED log has the following
once Node-red has started, point brwoser at http://192.168.1.1:1880 , this the IP of My raspbery pi in the local network
When I checked the open ports, I found only this 0.0.0.0:1880
Now, I configured the proxy as follow:
<virtual host *:80>
ProxyPreseveHost on
ProxyRequests off
ProxyPass / http:// 192.168.1.1:1880
ProxyPassReverse / http://192168.1.1:1880/
ServerName 192.168.1.1:80

when I checked it from another pc, it is open but it is blank,
when I monitor the traffic using wireshark , there is http traffic and works , but it has some message like HTTP /1.1 400 bad request (application/json)
HTTP /1.1 304 not defined

the error log has
[proxy error]the error log has " connection confused: AH0114: HTTP : attempt t conect to 192.168.1.1 faild
[proxy_http: error] failed to make connection to backend 192.168.1.1
for previous configuration I also tried 127.0.0.1:1880 for proxypass and proxypassreverse , and localhost for server name the same problem

for previous configuration I also tried 127.0.0.1:1880 for proxypass and proxypassreverse , and servername localhost ...however, it is the same problem

When you access NR directly at http://192.168.1.1:1880 is that the admin interface or something else?

Also, I think your ServerName field is wrong, it should be a domain name and needs to be something that is externally understandable - either your (sub)domain name or the external IP address of your router.

Finally, you need to understand that what you are doing is quite dangerous. You are exposing Node-RED to the Internet with no protection whatsoever - this is ripe for being hacked.

Yes, I know this dangerous. but I am creating this in local network, as I need it in my experiments. what I mean, the whole my work in local network and till now I didn't add router, it is normal LAN. however, I need dashboard as web-page over http protocol (port 80) for my research.

my answer for your question, yes when I use 192.168.1.1:1880 from another device, it works. even when I use the web server and proxy, it works and there is http traffic but with error and blank page. further when I write 172.0.0.1:1880, and 0.0.0.0:1880 in this node-red device, it opens NR
regarding to Server Name, I change it many time, I put it localhost, as I dont have domain. and I think I don't need it as I need every thing in fake internet and local network .

OK, cool about the networking.

In terms of Apache, I'm afraid I haven't used it for a long time and never with Node-RED.

I unistalled apache and removed all the configuration
then have strated everything from the begining , however I got the same problem.
but now I used new device in the local network and when I put in the broswer, the node-red devices IP on port 80 (http://192.168.1.1:80)
I got the same node-red flow pages not UI or dashboard .
I dont know exactly what is the problem? but may be I should configure something in node-red

Ok. Finally, I fixed it after more than two weeks
The problem is Dashboard 2.12
I removed it and install version 2.11.0
and configure the proxy as what was published by @jaxon 77
and it works on port 80 and http traffic

thanks guys for your effort

That is not a fix, it is a workaround. Are you going to stick with that version for ever?

Yeah . You are right and I totally agree with you and I prefer to work with last version.
But I have priority and of course not to get the last version of node-red. I use it in my study and not for real case. So no matter.
Maybe there is a bug in version 2. 12, I tried all the possible solutions in Internet and among others, downgrading it is the only solution which worked with me.
If any one work with dashboard 2.12 , mod-proxy, and apache2.4.25 in raspberry pi and it works with him/her. I’d like to know, please?!