# The Node-Red with Apache2 - Reverse Proxy - Web Sockets Labyrinth

**URL:** <https://discourse.nodered.org/t/the-node-red-with-apache2-reverse-proxy-web-sockets-labyrinth/68263>\
**Category:** General\
**Created:** [27 September 2022 00:49 UTC](https://discourse.nodered.org/t/the-node-red-with-apache2-reverse-proxy-web-sockets-labyrinth/68263 "2022-09-27T00:49:44Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mrSidX](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mrsidx/32/18935_2.png) [@mrSidX](https://discourse.nodered.org/u/mrSidX)\
**Post date:** [27 September 2022 00:49 UTC](https://discourse.nodered.org/t/the-node-red-with-apache2-reverse-proxy-web-sockets-labyrinth/68263/1 "2022-09-27T00:49:44Z")

</div>

**Summary of Issues:** NR Proxy Routing in the Apache2 - `conf` files for `Virtual Host`, WSS connection errors, Cannot Click Inject Nodes, Dashboard "Not Loading"

**Scenario:**

I am consolidating multiple websites I host onto one server and successfully setup majority of my static sites to the one one cloud server. I have a NR instance running alongside with them attached to it's own Apache2 routed `ServerAlias`

**Problem:** The NR instance is giving issues after I manage the Apache2 `conf` settings for the Virtual Host associated with NR.

My case scenario with NR is that I have ( pardon if overly detailed)

```auto
~/www/server1.com
~/www/server2.com
~/www/nr-server3.com

```

and those are symlinked to the Apache html folders:

```auto
/var/www/server1.com
/var/www/server2.com
/var/www/nr-server3.com <---- (This is not populated with anything,  
NR will be serving via http node endpoints)

```

**Node-Red Settings worth noting:**

```auto
httpAdminRoot: '/admin',
httpStatic: '/home/ubuntu/www/nr-server3.com/public_html',

```

**Apache Configuration:**  
(Running on Ubuntu)  
Using Certbot as the CA I have a file:  
`/etc/apache2/sites-available/nr-server3.com-le-ssl.conf`

Inside the File: (anonymized)

```auto
<VirtualHost *:443>
        # The ServerName directive sets the request scheme, hostname and port that
        # the server uses to identify itself. This is used when creating
        # redirection URLs. In the context of virtual hosts, the ServerName
        # specifies what hostname must appear in the request's Host: header to
        # match this virtual host. For the default virtual host (this file) this
        # value is not decisive as it is used as a last resort host regardless.
        # However, you must set it for any further virtual host explicitly.
        #ServerName www.example.com

        SSLProxyEngine On
        ProxyPreserveHost On
        ProxyRequests Off

        ProxyPass /admin/comms wss://localhost:1880/admin/comms
        ProxyPassReverse /admin/comms wss://localhost:1880/admin/comms

        ProxyPass / https://localhost:1880/ connectiontimeout=5 timeout=30
        ProxyPassReverse / https://localhost:1880/

        ServerAdmin webmaster@nr-server1.com
        ServerName nr-server1.com
        ServerAlias nr-server1.com

        DocumentRoot /var/www/nr-server1.com/public_html
   
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

SSLCertificateFile /etc/letsencrypt/live/nr-server3.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/nr-server3.com/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
</IfModule>

```

**Further:**

I've had issue with what I listed above and it started out with the WSS connection issues. I seem to have the `/admin/comms/` part correct in the Apache settings, because now it doesn't complain about `wss` disconnection.

But I cannot get the `Inject` node to work in the IDE, and Dashboard `/ui` is console complaining that it cannot load: `GET https://nr-server3.com/ui/loading.html 404 (Not Found)` , Which displays some elements, but the buttons are not working.

At this point I'm thinking some setting in the Apache2 `/etc/apache2/sites-available/nr-server3.com-le-ssl.conf` are not working, in relation to routing the `wss` essentials / endpoints / or whatever it needs.  
and possibly my NR `settings.js` might need some adjustment as well... ?

I appreciate any assistance in clarifying this process of essentially turning NR into a fully working "Virtual Host" behind Apache2, with wss, and my case scenario where I am serving NR `httpStatic` content in a different folder.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [26 November 2022 00:50 UTC](https://discourse.nodered.org/t/the-node-red-with-apache2-reverse-proxy-web-sockets-labyrinth/68263/2 "2022-11-26T00:50:01Z")

</div>

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