2

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?

Mwavu
  • 1,826
  • 6
  • 14
  • Do shell command `docker logs name_of_shinyproxy_container` and report error messages. You might also want to enble CORS. – danlooo Jun 29 '22 at 07:14
  • @danlooo I've looked up `docker logs` command and it requires container id. When I do `docker container ls | grep "theapp"` it's not there. But I can find it among docker images by doing `docker images | grep "theapp"`. I'm assuming this is because shinyproxy only spins up the containers when necessary, but I might be wrong. – Mwavu Jun 29 '22 at 07:28
  • You need to do `docker logs` on the container and not the image. The term `theapp` might not be part of the container name. Do `docker container ls` without the grep and search for them manually. Docker logs works even when the container is stopped but not removed yet. – danlooo Jun 29 '22 at 07:31
  • @danlooo Gatchu. Had to add `-a` flag. There are no errors in the logs. – Mwavu Jun 29 '22 at 07:41
  • You need to put middleware in your proxy to strip parts of the url, because the shiny app is very confused with the domain you are using. The easiest and cleanest way is to use a subdomain for the app e.g. http://localhost:8080/app/01_hello goes directly to theapp.company.com – danlooo Jun 29 '22 at 07:45
  • @danlooo is that not what I've done in the configuration file? I'm a bit confused here. – Mwavu Jun 29 '22 at 07:59
  • Unfortunately, it did not work, because theapp.company.com will route to the landing page of all apps but not to the hello app. many firewalls block ports other than 443 and 80. Bind the shinyproxy to port 80 instead of 8080 so that serveripaddress/app/01_hello will work – danlooo Jun 29 '22 at 08:12

1 Answers1

1

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)

Johannes Titz
  • 972
  • 6
  • 11