A proxy for RStudio Server like ShinyProxy

Is it possible to have a solution for that?

Kind regards.

Hello @DuyThoNguyen35 ,

We have an IDE for data science called Architect (see https://www.openanalytics.eu/architect) that has a server version Architect Server. This is in use by many companies as an alternative for RStudio Server. The main difference is that an Architect client is a desktop application that connects to an Architect server over SSH (typically) and does not live in a browser. If you would like to have a web-based IDE, that is possible too (using Architect with a broadway backend in a setup similar to ShinyProxy).

HTH,
Tobias

1 Like

Hi,

I had a similar idea. I wanted to start rstudio-server just like an app within the shinyproxy.

  1. I downloaded the rocker/rstudio Dockerfile (rocker/rstudio at master · rocker-org/rocker · GitHub) and modified it to use port 3838 instead of 8787

EXPOSE 3838
echo “www-port=3838” >> /ect/rstudio/rserver.conf

  1. built it
    docker build -t rstudio-server .

  2. modified the application.yml file in the apps section

  - name: rstudio
    docker-cmd: ["/init"]
    docker-image: rstudio-server
    ldap-groups: [admin]

The container spins up:

Creating container with ContainerConfig: ContainerConfig{hostname=null, domainname=null, username=null, attachStdin=null, attachStdout=null, attachStderr=null, portSpecs=null, exposedPorts=[3838], tty=null, openStdin=null, stdinOnce=null, env=[SHINYPROXY_USERNAME=sam], cmd=[/init], image=rstudio-server, volumes=null, workingDir=null, entrypoint=null, networkDisabled=null, onBuild=null, labels=null, macAddress=null, hostConfig=HostConfig{binds=null, containerIDFile=null, lxcConf=null, privileged=null, portBindings={3838=[PortBinding{hostIp=0.0.0.0, hostPort=20000}]}, links=null, publishAllPorts=null, dns=null, dnsSearch=null, extraHosts=null, volumesFrom=null, capAdd=null, capDrop=null, networkMode=null, securityOpt=null, devices=null, memory=null, memorySwap=null, cpuShares=null, cpusetCpus=null, cpuQuota=null, cgroupParent=null, restartPolicy=null, logConfig=null, ipcMode=null}, stopSignal=null}

but the browser just gives me the good old 404 error…

Any advice how to get forward or is this even remotely possible? I think it could have something do with rstudio proxy settings.

2 Likes

Hi @tverbeke. I didn’t quite understand your answer. It is now 2018, and there appears to be a product called Architect Server. Can multiple instances of this run on a single server. If not, would it be possible to hack ShinyProxy to make that work?

Hi @samsam. Did you make any progress on this? It would be hugely beneficial for the datascience community.

Hi @abalter, Architect Server can manage as many R sessions on a single server as you wish, indeed but does not use Docker technology (and will not run inside ShinyProxy). Docker-based versions will be released in the coming months.

HTH,
Tobias

1 Like

That’s really cool. Can’t wait to try it out.

Bumping this.

Has anyone managed to get RStudio Server to work behind ShinyProxy? I tried @samsam’s method and didn’t get anywhere, so that hasn’t changed.

I’m going to try creating a custom Dockerfile. If I’m successful I’ll let you all know.

UPDATE:

I wrote a Dockerfile that ran RStudio Server with no issues on my localhost.

FROM r-base

RUN apt-get update && apt-get install -y \
    gdebi-core
RUN wget https://download2.rstudio.org/rstudio-server-stretch-1.1.463-amd64.deb
RUN gdebi -n rstudio-server-stretch-1.1.463-amd64.deb

RUN echo "www-port=3838" >> /etc/rstudio/rserver.conf

EXPOSE 3838

CMD ["/usr/lib/rstudio-server/bin/rserver","--server-daemonize=0","--auth-none=1"]

Unfortunately I got a 404 error when I tried to run it on Shinyproxy.

  - id: rstudio
    display-name: RStudio
    container-cmd: ["/usr/lib/rstudio-server/bin/rserver","--server-daemonize=0","--auth-none=1"]
    container-image: rstudio

If someone else has better luck, please let us know!

One similar option is to run JupyterLab and have the Jupyter Rsession Proxy manage the connection to RStudio. Much like ShinyProxy, Jupyter Rsession Proxy, when used with JupyterLabs Docker Spawner, can spin up a docker image for every user who connects so each user is using RStudio in their own container.

My implementation looks like this:

jupyterlab jupyterlab.gif

1 Like

Hi,

You get the error since rstudio-server tries to redirect to /auth-sign-in on the host server and this fails.
One way to fix this is to disable authentication. For rocker/rstudio image this can be done easily with passing environment variable DISABLE_AUTH=true. However then there is also an issue of running in iframe, that is disabled by default, and needs to be changed by adding www-frame-origin parameter to the /etc/rstudio/rserver.conf (see https://docs.rstudio.com/ide/server-pro/access-and-security.html#frame-origin). But this file gets replaced if the env var above is specified :-/
So one working solution is as follows:

  1. Build a custom image (say my/rstudio) based on rocker/rstudio from the following Dockerfile:
FROM rocker/rstudio
RUN echo "www-frame-origin=same" >> /etc/rstudio/disable_auth_rserver.conf  # NB: this file is only used by rocker if the env var below is specified
  1. In the application.yml specify the following:
  - id: rstudio
    description: Run rstudio inside ShinyProxy!
    container-image: my/rstudio
    container-env:
      DISABLE_AUTH: true
    port: 8787

It works, but this is just a proof-of-concept…for proper use you would probably want to mount volumes (ideally per user) etc

3 Likes

@mnazarov

Thanks a million!

I’m going to go ahead and implement this. In the near future I’ll be attempting to mount some volumes to users. If I get that figured out I’ll post back here with how I did it.

Hi @five_cents,

You can use Spring Expression Language for that (supported since ShinyProxy 2.0.4):

proxy:
     ...
  specs:
  - id: yourapp
    ...
    container-volumes: [ "/home/#{proxy.userId}:/home/#{proxy.userId}" ]

See also https://www.containerproxy.io/containerspecs/#expressions

Hope this helps!

Best,
Tobias

3 Likes

This info was invaluable to getting RStudio to run in my ShinyProxy/Shiny/RStudio Docker stack. Though, in my configuration, user session states are not retained, but their preferences (e.g., themes) are.

See a working example here:

4 Likes

You must also set the WWW_ROOT_PATH.

See: https://github.com/openanalytics/shinyproxy-rstudio-ide-demo

1 Like