Auth redirects with RStudio behind proxy


I have RStudio (community edition) running behind a proxy using Caddy. I map RStudio
to a subdirectory like so:

  proxy /rstudio rstudio:8787 {
    without /rstudio
    header_upstream Host {host}/rstudio
  redir /rstudio /rstudio/ 307

(In this case Caddy and RStudio are running as separate docker images, so rstudio is the name of the Docker service)

This mostly works, but when I am not logged in to RStudio, and go to, it redirects to, not

I attempted to fix this by adding another redirect:

  redir /auth-sign-in /rstudio/auth-sign-in 307

This works to get to the login page, but after I log in it then redirects to, not Is this an RStudio bug or is there something I am missing? I note a few similar cases with other proxy software on the old support site: apache case, nginx case.


Have you seen the support page for reverse proxying RStudio Server?

I haven’t used Caddy, and it isn’t one of the options listed, but the theme from the nginx and Apache instructions (both of which I’ve used at one point or another) is that custom subdirectory paths require some kind of rewriting on the response to deal with the paths returned by the server.


Thanks, @nick. According to the folks at the caddy forum, I need for RStudio to know it’s base path so it can redirect properly ( I haven’t found anything in the link you gave or elsewhere that suggests RStudio has such a configuration setting. So maybe caddy doesn’t support this? If not, I’d be interested to understand what lines in the nginx config fix this. Or does RStudio detect proxying from nginx or apache somehow? Maybe a header needs to be set for it to do so?


To the best of my knowledge, RStudio does not support changing the base URL, and isn’t providing any particular “help” when behind any reverse proxy. For nginx, this is the line that does the “magic”:

rewrite ^/rstudio/(.*)$ /$1 break;

It seems like Caddy supports a similar directive, but I don’t know the right way to do it myself.

Also, note that RStudio needs websocket support to work properly, and that often needs additional modification to work properly beyond the standard reverse proxy config.


I think the equivalent in caddy is

rewrite {
  from ^rstudio/(.*)$
  to /{1}

But I believe the without /rstudio proxy directive is what is supposed to accomplish this. It sends the path to the rstudio server without the /rstudio prefix. But I want redirection to include this prefix when RStudio sends the user to a different URL, including /, but not anytime the user goes to /.

Just thinking though this out loud…I don’t get how this succeeds in nginx without RStudio being aware of its base URL, unless it’s operating in a different way than I understand (likely).


@jonathan Any thoughts on whether the issue here lies with Caddy, RStudio, or me?


I’m not familiar with Caddy, but I believe what happens in the nginx case is that RStudio emits absolute paths when it serves redirects, and nginx rewrites them to fall under /rstudio/ before it passes the request on to the browser.

RStudio itself is proxy-agnostic; if served at a non-root URL, the proxy is responsible for doing the appropriate path transformations.


OK, my conclusion here is that Caddy does not implement the equivalent of nginx’s proxy_redirect. It appears to be half-heartedly in the pipeline: . Thanks all for chipping in.