Search code examples
rdockershinyshinyproxy

Configure subdomain shinyproxy


First things first, I'm quite a beginner at hosting shiny apps on docker and shinyproxy. The terms I use might be a bit layman and incorrect.

I have my application running well on shinyproxy and can be accessed through serveripaddress:8080/app/01_hello.

The problem comes when I try to use a link ie. theapp.company.com instead of the ip address. This is what it shows when I go to the link:

subdomain-error

Here is the necessary part of 01_hello nginx configuration file:

   location / {
       proxy_pass          http://localhost:8080/app/01_hello;

       proxy_http_version 1.1;
       proxy_set_header Upgrade $http_upgrade;
       proxy_set_header Connection "upgrade";
       proxy_read_timeout 600s;

       proxy_redirect    off;
       proxy_set_header  Host              $http_host;
       proxy_set_header  X-Real-IP         $remote_addr;
       proxy_set_header  X-Forwarded-For   $proxy_add_x_forwarded_for;
       proxy_set_header  X-Forwarded-Proto $scheme;
   }

But when I change the proxy_pass to:

proxy_pass          http://localhost:8080;

then go to theapp.company.com it shows the landing page of all apps on shinyproxy and then I can go to theapp.company.com/app/01_hello which works, but not what I want.

I just want it to be theapp.company.com. How do I achieve this?


Solution

  • I have a very similar setup and it works for me. I believe the problem is that you are using "app" instead of "app_direct" in proxy_pass. This is my nginx proxy config (localhost instead of 127.0.0.1 or 0.0.0.0 should be fine):

    location / {
       proxy_pass          http://127.0.0.1:8080/app_direct/mimosa/;
    
       proxy_http_version 1.1;
       proxy_set_header Upgrade $http_upgrade;
       proxy_set_header Connection "upgrade";
       proxy_read_timeout 600s;
    
       proxy_redirect    off;
       proxy_set_header  Host              $http_host;
       proxy_set_header  X-Real-IP         $remote_addr;
       proxy_set_header  X-Forwarded-For   $proxy_add_x_forwarded_for;
       proxy_set_header  X-Forwarded-Proto $scheme;
    
     }
    

    Using the /app/ path seems to confuse shinyproxy. If you run shinyproxy via java directly (with your setup) you will see requests that do not match the correct URI. You can also check the console (F12 in chromium), which shows failed loading of resources.

    Not sure if this can be fixed easily with the nginx config.

    Usually, the navbar at the top is not needed, so app_direct is a simple solution. Hope it helps. If not, can you post your entire nginx config and application.yml? (you can remove sensitive parts)