RStudio behind a reverse proxy [nginx in my case]

I am running RStudio IDE servers in a Kubernetes cluster: each user gets an individual instance of the same docker image [with their own home-directory mounted in]

The normal routing path is external url -> k8 ingress rule catches /user/ -> nginx service proxy-pass based on location -> specific pod

I cannot get a clean response from an RStudio server, accessing it through router

All user-servers are named user-<uuid>

The nginx has a Location definition thus:

  location ~ /user/([a-z0-9]+)/rstudio {
    proxy_hide_header Content-Security-Policy;
    proxy_pass http://user-$1.${POD_NAMESPACE}.svc.cluster.local:8787;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection $connection_upgrade;
    proxy_set_header Host user-$1:8787;
    client_max_body_size 0;

    proxy_set_header X-Forwarded-Proto $proto;
    proxy_set_header X-Forwarded-Port $port;
    add_header X-Clacks-Overhead "RStudio" always;
    proxy_set_header User-Agent "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:121.0) Gecko/20100101 Firefox/121.0";

[ ${POD_NAMESPACE} ensures that it references the pod in my namespace and doesn't magically connect to someone elses service; $proto & $port are for http/https & 443/80; $1 is the UUID specific to the user. X-Clacks-Overhead lets me confirm that this location definition is used ]

If I work from the router container in the cluster [so bypassing any possible contamination from external factors] - I can get a named file:

  • curl http://<user-1234>:8787/rstudio.css == downloads file
  • curl http://<user-1234>:8787/notrstudio.css == page not found page
  • curl http://<nginx-service-name>/<location>/rstudio.css == 404

I've tried various combinations of X-RStudio-Root-Path & www-root-path.... and I've essentially run myself in circles - and frazzled the brain of a colleague who tried to help :slight_smile:

Two questions:

  1. Can someone explain the actual effects of X-RStudio-Root-Path & www-root-path- the documentation is not that clear
  2. Has anyone got a working instance, and able to share their config?

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.