-
Notifications
You must be signed in to change notification settings - Fork 183
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Path prefix does not work as expected with RStudio server and Traefik #388
Comments
The ability to change the base URL with an environment variable is common in Docker images and makes sense. |
I believe this can be solved entirely without rstudio configuration but externally by a reverse proxy. I stumbled onto this while doing something similar and you can use the
You can make the path deeper if you like in the same manner. One important note, if you route to rstudio under a prefix, e.g. |
@saepire I did what you recommended and managed to get it working with the latest image. No further changes needed! The version: "3.3"
services:
traefik:
image: "traefik:v2.6"
container_name: "traefik"
command:
#- "--log.level=DEBUG"
- "--api.insecure=true"
- "--providers.docker=true"
- "--providers.docker.exposedbydefault=false"
- "--entrypoints.web.address=:80"
ports:
- "80:80"
- "8080:8080"
volumes:
- "/var/run/docker.sock:/var/run/docker.sock:ro"
# RStudio server
rstudio:
image: "rocker/rstudio:latest"
# IMPORTANT: this name MUST be used in traefik's routers service
container_name: "rstudio-server"
restart: "unless-stopped"
environment:
- PASSWORD=rstudio
labels:
- "traefik.enable=true"
- "traefik.http.routers.rstudio-server.rule=Host(`localhost`) && PathPrefix(`/rstudio`)"
- "traefik.http.routers.rstudio-server.entrypoints=web"
- "traefik.http.middlewares.rstudio-server-path-strip.stripprefix.prefixes=/rstudio"
- "traefik.http.middlewares.rstudio-server-path-strip.stripprefix.forceSlash=false"
- "traefik.http.middlewares.rstudio-server-root-path-header.headers.customrequestheaders.X-RStudio-Root-Path=/rstudio"
- "traefik.http.routers.rstudio-server.middlewares=rstudio-server-root-path-header,rstudio-server-path-strip"
- "traefik.http.services.rstudio-server.loadbalancer.server.port=8787"
Cheers! |
@eitsupi Was this feature added later (to change the base URL through configuration)? I see the documentation still describes setting up a reverse proxy with Caddy for this purpose. |
I don't think so. |
https://z2jh.jupyter.org/en/stable/ is another common and well-documented way to run Rocker-based images with rstudio on any kubernetes system |
What is this issue about?
Some users have reported difficulties to setup RStudio server with Traefik reverse proxy using a path prefix (e.g., www.example.com/rstudio). The reference discussions are linked below:
The problem occurs because not only Traefik, but also Rstudio server must be configured accordingly.
How to test it?
1. Basic example: does NOT work
docker-compose.yml
docker-compose up -d
docker-compose down
2. Stripping prefix (Traefik): still does NOT work
docker-compose.yml
docker-compose up -d
docker-compose down
How to fix it?
The problem occurs because RStudio server does not know what path it is being served from. One can find all RStudio Server Configuration here. In order to fix this issue it is necessary to set the www Setting
www-root-path
in/etc/rstudio/rserver.conf
to match the proxy prefix (e.g., /rstudio).wwwsettings.sh
docker-compose.yml (NOTE: /home/dev/wwwsettings.sh is an absolute path on the host machine and must be modified accordingly)
docker-compose up -d
docker-compose down
To allow the deployment of RStudio Server on a self-service container service delivery platform (e.g., Portainer) with no need to mount a volume I'd suggest to place the content of
wwwsettings.sh
inrocker-versioned2/scripts/init_set_env.sh
(or inrocker-versioned2/scripts/init_userconf.sh
).rocker-versioned2/scripts/init_set_env.sh
Lines 1 to 14 in 83651a7
In the future, it may be relevant to expose other RStudio server configuration settings/properties. Just let me know in case I should send the proposed solution as a pull request.
Cheers!
The text was updated successfully, but these errors were encountered: