Shiny apps greyed out when run from rstudio behind apache2 proxy on digitalocean ubuntu 20.4 server

I'd be really grateful for any input on the following problem.

I have rstudio server installed on a digitalocean server, proxied by apache2 with a lets encrypt cert.

I can connect to the rstudio ide, everything works except running shiny apps.

For example if I run shiny::runExample('01_hello') this is the error I get (the 2nd last path segment varies depending on the port chosen to run the shiny app)

"shinyapp.ts:319 WebSocket connection to 'wss://some-site.com/rstudio/p/8b910e25/websocket/' failed: "

The relevant block in shinyapp.ts is:

  if (!/\/$/.test(defaultPath)) defaultPath += "/";
  defaultPath += "websocket/";
  var ws = new WebSocket(protocol + "//" + window.location.host + defaultPath);
  ws.binaryType = "arraybuffer";
  return ws;
};

I have seen this when 'inspect'ing the page during a reload (Although I can't remember how I found it):

"TypeError: Cannot read properties of undefined (reading 'requestContent')"

So maybe there is no data being presented to the WebSocket call.

The inspector shows the following initiator chain for the websocket request:

https://some-site.com/rstudio/p/8b910e25/
https://some-site.com/rstudio/p/8b910e25/shared/shiny.min.js
wss://some-site.com/rstudio/p/8b910e25/websocket/

After consulting many different sources and trying plenty of different hacks the apache2 configuration I have set up is:

================================================
Main site config in /etc/apache2/sites-available

<IfModule mod_ssl.c>
<VirtualHost *:443>
    ServerAdmin webmaster@localhost
    ServerName some-site.com
    ServerAlias www.some-site.com
    DocumentRoot /var/www/some-site.com
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

    <Directory /var/www/>
       Options +FollowSymlinks
       AllowOverride All

      <IfModule mod_dav.c>
        Dav off
      </IfModule>

       SetEnv HOME /var/www
       SetEnv HTTP_HOME /var/www
     </Directory>


SSLCertificateFile /etc/letsencrypt/live/some-site.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/some-site.com/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf


</VirtualHost>
</IfModule>

============================================
rstudio.conf in /etc/apache2/sites-available

</Proxy * >
    Allow from localhost
</Proxy>
 
RewriteEngine on
RewriteCond %{HTTP:Upgrade} =websocket
RewriteRule /rstudio/(.*) ws://localhost:8787/$1  [P,L]
RewriteCond %{HTTP:Upgrade} !=websocket
RewriteRule /rstudio/(.*) http://localhost:8787/$1 [P,L]
ProxyPass /rstudio/ http://localhost:8787/
ProxyPassReverse /rstudio/ http://localhost:8787/
ProxyRequests Off

The R version is 4.1.1
Shiny package version : 1.7.1
RStudio server package : rstudio-server-2021.09.0-351-amd64.deb.

shiny server is installed and working fine.

Thanks!