Map subdirectory to containerized ShinyProxy w/ Apache

Hi all,
I am trying to add ShinyProxy to our server (https://www.eample.com), w/ access from our portal. I have followed the steps here and, locally, everything run.

I have already linked RStudio server (https://example.com/rstudio/) and Shiny server (https://example.com/shiny/) to the portal, but cannot link ShinyProxy: login https://example.com/shinyproxy/login page is shown (w/out formatting, that is quite strange) automatically at the first visit of https://example.com/shinyproxy/, but after login, the page is redirected to https://www.example.com/login which (clearly) is missing (“Not Found/The requested URL was not found on this server.”).

The container is run using:

# docker run -d -v /var/run/docker.sock:/var/run/docker.sock --net sp-example-net -p 8080:8080 shinyproxy-example

Here below my /etc/apache2/default-ssl.conf

<IfModule mod_ssl.c>
	<VirtualHost _default_:443>
		ServerAdmin webmaster@localhost

        DocumentRoot /var/www/html

		ErrorLog ${APACHE_LOG_DIR}/error.log
		CustomLog ${APACHE_LOG_DIR}/access.log combined

		SSLEngine on
		SSLCertificateFile          /etc/apache2/ssl/example.crt
		SSLCertificateKeyFile    /etc/apache2/ssl/example.key
		SSLCertificateChainFile /etc/apache2/ssl/DigiCertCA.crt



		<FilesMatch "\.(cgi|shtml|phtml|php)$">
				SSLOptions +StdEnvVars
		</FilesMatch>
		<Directory /usr/lib/cgi-bin>
				SSLOptions +StdEnvVars
		</Directory>

        <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

        
        RewriteEngine on
        RewriteCond %{HTTP:Upgrade} =websocket
        RewriteRule /shinyproxy/(.+) ws://localhost:8080/$1  [P,L]
        RewriteCond %{HTTP:Upgrade} !=websocket
        RewriteRule /shinyproxy/(.+) http://localhost:8080/$1 [P,L]
        ProxyPass /shinyproxy/ http://localhost:8080/
        ProxyPassReverse /shinyproxy/ http://localhost:8080/
        ProxyRequests Off

        
        RewriteEngine on
        RewriteCond %{HTTP:Upgrade} =websocket
        RewriteRule /shiny((/[^/]+)/?(.*))?/?$ ws://localhost:3838$2/$3 [P,L]
        RewriteCond %{HTTP:Upgrade} !=websocket
        RewriteRule /shiny((/[^/]+)/?(.*))?/?$ http://localhost:3838$2/$3 [P,L]
        ProxyPass /shiny/ http://localhost:3838/
        ProxyPassReverse /shiny/ http://localhost:3838/
        ProxyRequests Off



	</VirtualHost>
</IfModule>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

What can be wrong, and what can I do to solve the problem?
Thank you very much.
Corrado.

Hi

If you are running ShinyProxy on a subpath (e.g. /shinyproxy) instead of at the root of the url (i.e. /), you need to specify the context-path property as documented here https://shinyproxy.io/documentation/configuration/#general

1 Like

Great, thank you! I had missed it.

So now everything works!

For everyone who could need it (and future me too ;-)), my current configuration files are as follow:

  • default.ssl.conf
<IfModule mod_ssl.c>
	<VirtualHost _default_:443>
		ServerAdmin webmaster@localhost

        DocumentRoot /var/www/html

...

        <Proxy *>
            Allow from localhost
        </Proxy>

        ProxyPass /sp/ http://localhost:8080/sp/
        ProxyPassReverse /sp/ http://localhost:8080/sp/
        ProxyRequests Off

	</VirtualHost>
</IfModule>
...
  • application.yml
proxy:
   port: 8080
   docker:
     internal-networking: true
   ...

server:
  useForwardHeader: true
  servlet:
    context-path: /sp

Thank you again!!
Corrado.

1 Like