Load balancing bare shiny app docker container


#1

Hello everyone!

I want to apologize for the issue not on the topic, but I have no idea how to solve this issue. I have a Shiny app in the docker container. I want to scale it. I run several containers on different ports. All works, if go to address on localhost: port_number. But when I try to do load balancing (upstream nginx), problems begin. NGINX can not load js and css files from containers. The Shiny application is loaded, but NGINX can not load js and css files. For example, the leaflet does not work, and in the browser console the following error:
GET http: // my_ip/minichart-0.2.2/leaflet.minicharts.min.js 404 (not found).
Could you tell me how to solve this problem?

Addition:
When I run app in container (ONE app in ONE container) behind NGINX it works well.
configuration file:
server {
listen 80;
#server_name myapp.com www.myapp.com;
location / {
proxy_pass http://localhost:3838;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection “upgrade”;
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;
proxy_cache_bypass $http_upgrade;
proxy_read_timeout 90;
}
}

But if I clone container (ONE conteiner runs on 3838 port, SECOND container with the same app runs on 3839 port), I will get errors: the Shiny application is loaded, but NGINX can not load js and css files. This both containers run behind nginx with other configuration.
configuration file:

upstream myapp1 {
server localhost:3838;
server localhost:3839;
}

server {
listen 80;
#server_name myapp.com www.myapp.com;
location / {
proxy_pass http://myapp1;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection “upgrade”;
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;
proxy_cache_bypass $http_upgrade;
proxy_read_timeout 90;
}
}

B.W. Alexey