Traefik and RStudio Reverse Proxy

Hello, I basically have the same question found here: Traefik and Rstudio

I am struggling to translate the NGINX code here: Running RStudio Server with a Proxy – RStudio Support

What I have:

version: '3.8'

services:
  rstudio:
    image: rocker/rstudio:4.0.3
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro
    environment:
      - USER=user
      - PASSWORD=rstudio
      - ADD=shiny
    networks:
      - traefik-public
    deploy:
      replicas: 1
      placement:
        constraints:
          - node.role == manager
      labels:
	- traefik.enable=true
        - traefik.docker.network=traefik-public
        - traefik.constraint-label=traefik-public
        - traefik.http.routers.rstudio-http.rule=Host(`example.com`) && PathPrefix(`/rstudio`)
        - traefik.http.routers.rstudio-http.entrypoints=http
        - traefik.http.routers.rstudio-http.middlewares=https-redirect
        - traefik.http.routers.rstudio-https.rule=Host(`example.com`) && PathPrefix(`/rstudio`)
        - traefik.http.routers.rstudio-https.entrypoints=https
        - traefik.http.routers.rstudio-https.tls=true
        - traefik.http.routers.rstudio.middlewares=rstudio-replacepathregex
        - traefik.http.middlewares.rstudio-replacepathregex.replacepathregex.regex=^/rstudio/(.*)$$
        - traefik.http.middlewares.rstudio-replacepathregex.replacepathregex.replacement=/$$1
        - traefik.http.services.rstudio.loadbalancer.server.port=8787

networks:
  traefik-public:
    external: true

To anyone who is reading this in 2023:

This GitHub issue saved me after wasting several hours facing the same problems: