Running ShinyApps from RStudio-Server behind Nginx proxy

I don't see anything obvious in the code you quote. Can you provide a complete but minimal example that shows the error?

Here a minimal working example with two files:

docker-compose.yml

version: '3.1'

services:
    proxy:
        image: nginx:alpine
        ports:
            - 80:80
        volumes:
            - ./default.conf:/etc/nginx/conf.d/default.conf


    rstudio:
        image: rocker/rstudio:3.5.1
        environment:
            PASSWORD: password

default.conf

  map $http_upgrade $connection_upgrade {
    default upgrade;
    ''      close;
  }

  server {
    listen 80;

    location /rstudio/ {
      rewrite ^/rstudio/(.*)$ /$1 break;
      proxy_pass http://rstudio:8787;
      proxy_redirect http://rstudio:8787/ $scheme://$host/rstudio/;
      proxy_http_version 1.1;
      proxy_set_header Upgrade $http_upgrade;
      proxy_set_header Connection $connection_upgrade;
      proxy_read_timeout 20d;
    }
  }

After docker-compose up I can access http://localhost/rstudio and create and test Shiny applications.