Apache2 websocket

Hey

im a hobbyist and try to make my own secure webinterface for my home automation
im stuck at my proxy i use apache2 and i have nodered working with websocket but i cant get it to work with uibuilder

this is what my error.log say
[autoindex:error] [pid 25220] [client 82.163.40.94:60767] AH01276: Cannot serve directory /var/www/test/uibuilder/vendor/socket.io/: No matching DirectoryIndex (index.php) found, and server-generated directory index forbidden by Options directive, referer: https://test.domain.com/

this is my feedback from chrome


and this is my apache2 config

  GNU nano 5.4                                                                                                                            showcontrol.laurijnproductions.com-le-ssl.conf
<IfModule mod_ssl.c>
<VirtualHost *:443>
        ServerAdmin test@domain.com
        ServerName test.domain.com

        Documentroot /var/www/test/
        DirectoryIndex index.php

        <Directory /var/www/test>
                Options FollowSymLinks
                Allow from all
                Require all granted
        </Directory>

        ErrorLog /var/log/apache2/test/error.log
        CustomLog /var/log/apache2/test/access.log combined
        SSLProxyEngine ON

        <Directory "/var/www/test/uibuilder/vendor/>
                Options +ExecCGI +Indexes +FollowSymLinks -MultiViews
                Require all granted
                Allow from all
        </Directory>

        Define SocketURL "/nodered/"

                <Location ${SocketURL}>
                                RewriteEngine on
                                RewriteCond %{HTTP:Upgrade} ^WebSocket$ [NC]
                                RewriteCond %{HTTP:Connection} Upgrade$ [NC]
                                RewriteRule .*/(.*) "ws://localhost:1880/$1" [P,L]

                                ProxyPass http://localhost:1880/
                                ProxyPassReverse http://localhost:1880/
                </Location>



        Define NodeRedURL "/nodered/"

                <Location ${NodeRedURL}>
                                RewriteEngine on
                                RewriteCond %{HTTP:Upgrade} ^WebSocket$ [NC]
                                RewriteCond %{HTTP:Connection} Upgrade$ [NC]
                                RewriteRule .*/(.*) "ws://localhost:1880/$1" [P,L]

                                ProxyPass http://localhost:1880/
                                ProxyPassReverse http://localhost:1880/
                </Location>
        ProxyPreserveHost On
        ProxyRequests Off
        SSLCertificateFile /etc/letsencrypt/live/test.domain.com/fullchain.pem
        SSLCertificateKeyFile /etc/letsencrypt/live/test.domain.com/privkey.pem
        Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
</IfModule>

can someone help me with it

kind regardz
Laurijn van den Heuvel

THat is your problem. You have set Apache to deliver from a fixed filing system location whereas Node-RED (via uibuilder) already serves that. If you wanted to do it that way, you would need to put the Socket.IO client library in that folder. But I don't recommend that since the client and server libraries need to be the same version or they may not work. So you really don't want to be manually managing that (unless you do for some reason).

Simply follow the instructions that are around somewhere for using Apache as a reverse proxy for Node-RED and everything should work as expected.

thank you for reaction what i want to do is that if i go to my domain test.domain.com that i landing on the webinterface whitout that i have to do test.domain.com:1880/something

Yup, loads of info on how to do this out on the web. I don't use Apache so I won't attempt to repeat it here.

https://www.google.com/search?q=node-red+apache+reverse+proxy&oq=node-red+apache+reverse+proxy

Thank you for the information

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.