Redirects for app running as subfolder behind proxy


(Noam Ross) #1

I have an app (RStudio) running behind a proxy using Caddy. I map it to a subdirectory like so:

  proxy /rstudio rstudio:8787 {
    without /rstudio
    header_upstream Host {host}/rstudio
    transparent
    websocket
  }
  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)

However, when RStudio redirects the user, it sends them to the top top level, not pages under my.site/rstudio. So to log in, it redirects to my.site/auth-sign-in, not my.site/rstudio/auth-sign-in.

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 my.site/, not my.site/rstudio/. I attempted to use the referrer, like so

redir 307 {
 if {>Referrer} has /rstudio
 / /rstudio
} 

This doesn’t seem to work. It may not recognize the referrer?


(Matt Holt) #2

Apps that are reverse-proxied need to be able to support that; RStudio either doesn’t or isn’t configured to preserve the URI.

I think there’s an open issue requesting a feature so that proxy can rewrite redirect locations for situations where backends don’t support reverse proxying.


(system) #3

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.