URL issue when using app_direct

Hi! :grinning:

I have several shiny apps deployed using shinyproxy, and I can see them if I visit www.mydomain.com/shiny

I was having trouble trying to make my app responsive using shinyproxy, and then someone suggested accessing the appy using www.mydomain.com/shiny/app_direct/myapp instead of www.mydomain.com/shiny/app/myapp (you can see the topic here). And it works great, because by using app_direct I got a responsive shiny app on my mobile phone, while using app/myapp the responsiveness wasn’t great.

The problem is: after changing to /app_direct/, my apache vhost looks like this:

<VirtualHost *:80>

RewriteEngine on
# force HTTPS
  RewriteCond %{HTTP:X-Forwarded-Proto} !=https
  RewriteRule .* https://%{HTTP:Host}%{REQUEST_URI} [L,R=permanent]

RewriteCond %{HTTP:UPGRADE} ^WebSocket$ [NC]
RewriteCond %{HTTP:CONNECTION} ^Upgrade$ [NC]
RewriteRule .* ws://localhost:8080%{REQUEST_URI} [P]

#Reverse proxy:
ProxyPass         /shiny
ProxyPassReverse  /shiny

ProxyRequests off

#Redirect login:
<Location /login>

RewriteRule ^ /shiny/app_direct/login


#Redirect register:
<Location /register>
RewriteRule ^ /shiny/app_direct/register



The only difference compared to the previous version is: I changed /app/ to /app_register/ in the Location

When I was using /app/, if I visited www.mydomain.com/register I could see the page but it wasn’t responsive. Now with /app_direct/ I can see the responsive page, but my browser’s URL changes to www.mydomain.com/shiny/app_direct/register instead of keeping www.mydomain.com/register. How can I prevent this change?

Thanks in advance,

This is more of an Apache question, not related to shinyproxy, so you might be able to find a solution faster somewhere else (like stackoverflow).
I am not an expert, but a quick search found that

Although rewrite rules are syntactically permitted in <Location> and <Files> sections (including their regular expression counterparts), this should never be necessary and is unsupported. A likely feature to break in these contexts is relative substitutions.


Hi @mnazarov,

Thanks for the answer.

The thing is: I was only using in the Location because the ProxyPass was giving me an error. For example, I can access all my shiny apps if I type www.mydomain.com/shiny. And it works fine, I can see the shinyproxy page listing the apps. The apache vhost code to allow that is:

ProxyPass         /shiny
ProxyPassReverse  /shiny

So I thought: maybe I can do the same and go directly to one of the apps. For example, if I want to be able to type www.mydomain.com/register and see the register app, then I should add this to my vhost file:

ProxyPass         /register
ProxyPassReverse  /register

But it doesn’t work. I got this error:

Shouldn’t this work as well and show me the register app?

In the ProxyPass I was using instead of So if I use this link I don’t get the above error anymore, everything works fine. But if I change it to to get the direct app, the page never loads and all my CPU resources is consumed by the command kswapd0, I can’t even restart the server through the command line because everything got super slow.

Note: when I was using the RewriteRule on the Location I wasn’t getting this problem, even when using app_direct.

I tried using a less complex app, and now I don’t have the kswapd0 problem. The simple app opens normally but the link in my browser changes to www.mydomain.com/shiny/app_direct/register/ instead of keeping the www.mydomain.com/register/ link.

I posted this question here because it seems that the best practice is to use the reverse proxy like this when we want to keep the browser’s URL:

ProxyPass         /register
ProxyPassReverse  /register

And it works fine. But if I change /app/ to /app_direct/ then the link in the browser changes from www.mydomain.com/register to www.mydomain.com/shiny/app_direct/register

It seems that maybe shinyproxy is doing something that forces the URL to change when using /app_direct/