Hi Everyone,
We are new users of Traefik and currently are stuck on how to redirect our request.
We are trying to access to Rstudio on port 8787 with a pathprefix /rstudio.
When we were using Nginx we had this trick :
server {
listen 80;
location /rstudio/ {
rewrite ^/rstudio/(.*)$ /$1 break;
proxy_pass http://localhost:8787;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_read_timeout 20d;
# Use preferably
proxy_set_header X-RStudio-Request $scheme://$host:$server_port$request_uri;
proxy_set_header X-RStudio-Root-Path /rstudio
# OR let the proxy rewrite the root path
proxy_redirect http://localhost:8787/ $scheme://$host/rstudio/;
proxy_cookie_path / /rstudio;
# OR existing X-Forwarded headers
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Proto $scheme;
# OR alternatively the Forwarded header (just an example)
proxy_set_header Forwarded "host=$host:$server_port;proto=$scheme;";
}
Now, we would like to tranfer it to Traefik. We have tried several configuration but with have no success on it.
Here's our Traefik Docker-compose line:
app1-rstudio:
container_name: app1-rstudio
image: rstudio
restart: always
privileged: true
networks:
- app1-network
ports:
- "6311:6311"
- "8787:8787"
environment:
- USER=rstudio
- PASSWORD=rstudio
volumes:
- ${APPDIR}filesapp1/scripting/rserver/:/home/rstudio/
- ${APPDIR}filesapp1/log/:/var/log/
- ${APPDIR}filesapp1/log/rserver/:/var/log/rserver/
labels:
- "traefik.http.routers.app1-rstudio.rule=Host(`localhost`) && PathPrefix(`/rstudio`)"
- "traefik.http.services.app1-rstudio.loadbalancer.server.port=8787"
- "traefik.http.routers.app1-rstudio.middlewares=app1-rstudio-replacepathregex"
- "traefik.http.middlewares.app1-rstudio-replacepathregex.replacepathregex.regex=^/rstudio/(.*)$$"
- "traefik.http.middlewares.app1-rstudio-replacepathregex.replacepathregex.replacement=/$$1"
- "traefik.enable=true"
Do you have any idea ?
Thank you for your support on that community.
Nooby Devops Team