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://' failed: "

The relevant block in shinyapp.ts is:

  if (!/\/$/.test(defaultPath)) defaultPath += "/";
  defaultPath += "websocket/";
  var ws = new WebSocket(protocol + "//" + + 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:

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
    DocumentRoot /var/www/
    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

       SetEnv HOME /var/www
       SetEnv HTTP_HOME /var/www

SSLCertificateFile /etc/letsencrypt/live/
SSLCertificateKeyFile /etc/letsencrypt/live/
Include /etc/letsencrypt/options-ssl-apache.conf


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

</Proxy * >
    Allow from localhost
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.


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

If you have a query related to it or one of the replies, start a new topic and refer back with a link.