Search code examples
apachecentosnode-red

Node Red - Lost Connection after redirection from port 1880 to a subdirectory


I have NodeRed installed on a VM with Cent OS 7.x and Apache 2.4.6 (CentOS).

If I open up the URL http://10.1.1.1:1880/ , everything is working. I can deploy nodes and see the debug. But I need Node Red on a special location. Next step was the configuration of a Proxy Pass in my httpd.conf .

Result: Node Red is available under http://10.1.1.1/nr/ . But after a few seconds I got the following error message.

Lost connection to server, reconnecting in 44s. Try now

Then I tried the same, also adding the port config to the 443, Result: Node Red is available underhttps://10.1.1.1/nr/ and it is working for a few seconds. Then the same error message ( + or – a few seconds) appear

Lost connection to server, reconnecting in 54s. Try now

Then I checked the Console in the Browser Error Code:

WebSocket connection to 'ws://10.1.1.1/nr/comms' failed: Error during WebSocket handshake: Unexpected response code: 404 a @ red.min.js:16

OK, it seems that this is a problem with the WebSocket. If someone have an idea, great because I tried different solutions added the Load Modules and have at the moment not really an idea. All the best.

ps: This is my proxy pass setting in the httpd.conf

<VirtualHost *:80>
  ServerName 10.1.1.1
  RewriteEngine On
  RewriteCond %{REQUEST_URI}  ^/socket.io            [NC]
  RewriteCond %{QUERY_STRING} transport=websocket    [NC]
  RewriteRule /(.*)           ws://localhost:1880/$1 [P,L]
  ProxyPass /nr/ http://127.0.0.1:1880/ timeout=360
  ProxyPassReverse /nr/ http://127.0.0.1:1880/
</VirtualHost>

Solution

  • I'm not sure what the RewriteRule is doing, but I think you need to be using the mod_proxy_wstunnel module and a ProxyPass rule like this:

    ProxyPass "/nr/comms"  "ws://localhost:1880/comms"