[repost from the slack channel, for people not there]
Testing the node-red, i start to think to use it to make some stand-alone boxes running the node-red-contrib-ui as front end, maybe with a small LCD screen or so (a-là timesquair.io, but with a screen)
So i tweak a bit the config to get the node-red working on localhost:80
Without running it on root mode.
first step:
few changes in the settings.js (or in a custom settings, to be launched with a -s parameter )
just uncomment the "httpAdminRoot" to force the node-red to move admin interface to localhost:1880/admin (or the path you like)
remember: with node-red-ui enabled, node-red serve UI interface to localhost:1880/ui
second step:
at this point i've managed to redirect ports from 1880 to 80 and /ui to /
for doing so, i've used haproxy (haproxy.org) a tiny, powerful reverse proxy and load balancer. just install it with
sudo apt-get install haproxy
haproxy work with a config file located in /etc/haproxy/haproxy.cfg.
This is the config i used:
global daemon maxconn 256 defaults mode http timeout connect 5000ms timeout client 50000ms timeout server 50000ms frontend http-in bind *:80 default_backend servers backend servers reqrep ^([^\ :]*)\ /(.*) \1\ /ui/\2 server server1 127.0.0.1:1880 maxconn 32
The server just wait for connection un port 80 and bind it to localhost:1880/ui (you can easily manage to move/use another address )
after setting up the haproxy, you can simple start it as a service
sudo service haproxy start
done!
All request to localhost will be now rediected to /ui, causing the UI interface to appear by default.
of course admin page will be still available at localhost:1880/admin
If you want to keep the 1880 port and give a default page to /ui, you can uncomment the httpStatic to set a local path ('/home/pi' in my case) where place a static html page to serve for localhost:1880
i've done a small redirect html to move the path to /ui automatically
<html> <head> <title>Redirect</title> <meta http-equiv="refresh" content="0;URL=http:/ui"> </head> <body> </body> </html>
The only "problem" found is the management of error pages, but i've already opened an issue on github
have fun!
sudo iptables -A PREROUTING -t nat -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 1880
to redirect the low numbered port 80 to 1880 - so you don't need to run as root. Even quicker and less dirty ;-)