Apache reverse proxy for Homegear Node-BLUE

To be able to set up a reverse proxy for Node-BLUE (the Node-RED fork contained in the Homegear software), you have to set up a websocket proxy as well.

To do this, the proxy_wstunnel module has to be activated. This can be done with

# a2enmod proxy_wstunnel

After restarting with systemctl restart apache2, the module list should show at least the following modules:

# apache2ctl -M | grep proxy
proxy_module (shared)
proxy_http_module (shared)
proxy_wstunnel_module (shared)

As the default Homegear configuration provides the websocket at / and the Node-BLUE webinterface at /node-blue, the requests have to be handled separately. So an example for a conf file (e.g. /etc/apache2/sites-available/nodeblue.conf) could look like this:

<VirtualHost *:80>
    ServerName nodeblue.example.com
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
    ProxyPreserveHost On
    ProxyRequests Off
    ProxyPassMatch    "^/(hgflows.*)$" "ws://localhost:2001/$1"
    ProxyPassReverse  "^/(hgflows.*)$" "ws://localhost:2001/$1"

    ProxyPass "/" "http://localhost:2001/node-blue/"
    ProxyPassReverse "/" "http://localhost:2001/node-blue/"
</VirtualHost>

For Node-RED, this should work as well, with the difference that the webinterface is located at / and the websocket is located at /comms.