I recently installed a cool tool called Node-RED which is a neat visual coding tool for IoT-type devices. It uses node.js, and listens on port 1880. However, I wanted Node-RED to function over port 80, to avoid having to type a port as part of the URL. I struggled getting the WebSocket connection to function correctly. I kept getting a HTTP response of 500.
I figured I might be able to save some other folks the trouble (and help me remember for next time). To get this to work on a system running Apache, you’re going to need to enable a few modules. I’m running Apache 2.4 on Raspbian Jessie for context.
sudo a2enmod proxy
sudo a2enmod proxy_http
sudo a2enmod proxy_wstunnel
sudo a2enmod proxy_html
sudo a2enmod proxy_fcgi
And configure your site listener to include the lines:
ProxyPass /nodered http://localhost:1880
ProxyPass /nodered/comms ws://localhost:1880/comms
ProxyPassReverse /nodered http://localhost:1880
ProxyPassReverse /nodered/comms ws://localhost:1880/comms
This way, you can simply navigate to your Node-RED installation on port 80 by simply using the URL http:///nodered/