-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
RStudio Server does not redirect properly when hosted under a subdirectory using a reverse proxy #1676
Comments
Just to report that I have the experienced the same issue. RStudio open source (1.1.383) running on Debian 9.2 and using Apache. I have followed the instructions provided on the support site. The redirect issue is exactly as described by @jstaf. |
I'm also running into this issue with RStudio and Nginx running via Docker Compose. For example, I have RStudio running in its own container on port 8000, and I have Nginx running in a different, linked container listening on port 8080. When I go to www.example.com:8080, RStudio redirects to www.example.com/auth-sign-in, losing the port in the process. Similar to the earlier comments, the sign-in page is not displayed and the app is not accessible. |
@jmcphers - Has there been any progress on this recently? This bug means that running under a subdirectory as described in the RStudio Admin Guide doesn't actually work. The ideal fix here would be to have a configuration option in |
After what feels like a day and a half of what feels like bashing my head against a wall, I think I've found a workaround for the issue using Apache. Using the following Apache conf appears to work in a VM (you can of course add SSL to the proxy using the usual methods). This example hosts RStudio under the example subdirectory <VirtualHost *:80>
ProxyPreserveHost on
# Some required redirects for rstudio to work under a subdirectory
Redirect /rstudio /rstudio/
Redirect /auth-sign-in /rstudio/auth-sign-in
Redirect /auth-sign-out /rstudio/auth-sign-out
Redirect /s /rstudio/s
Redirect /admin /rstudio/admin
# Catch RStudio redirecting improperly from the auth-sign-in page
<If "%{HTTP_REFERER} =~ /auth-sign-in/">
RedirectMatch ^/$ /rstudio/
</If>
RewriteEngine on
RewriteCond %{HTTP:Upgrade} =websocket
RewriteRule /rstudio/(.*) ws://localhost:8787/$1 [P,L]
RewriteCond %{HTTP:Upgrade} !=websocket
RewriteRule /rstudio/(.*) http://localhost:8787/$1 [P,L]
ProxyPass /rstudio/ http://localhost:8787/
ProxyPassReverse /rstudio/ http://localhost:8787/
</VirtualHost> How this works is that the |
Hello, this doesn't work when you're running, for example (in my case), two containers in a Kubernetes pod, where one is the R Studio (rocker/rstudio) and other is an Nginx proxy to make the R respond on a different path (like r.studio.domain/user). The reason for this is, that I'm trying to run R Studio in a Kubernetes environment at multi-user, putting each user on subpaths like: r.studio.domain/user1, r.studio.domain/user2, etc. (And, of course, nothing on '/', so that workaround doesn't work for me). As suggested by @jstaf would be great if we had a fix to have a configuration option in /etc/rstudio/rserver.conf to change the RStudio Server base address. |
Very late to the party but for for anyone using an nginx reverse proxy that is still looking for a fix: the rstudio proxy setup described in https://support.rstudio.com/hc/en-us/articles/200552326-Running-RStudio-Server-with-a-Proxy should work with the following edit: Change My use case is identical to @jeandevops's and this worked for me. |
Another year later, and I'm still running into this issue on nginx. I can manually enter the paths |
Apologies for this problem. Here's a similar example that I tested that works where Apache is listening on https and using a /rstudio path prefix. Note that when you set X-RStudio-Root-Path and X-Forwarded-Proto, you no longer need the rewrite rules since RStudio will be generating the correct external URLs in the first place. Make sure to change example.com with the external domain of your proxy server..
|
@jeffvroom thank you, this did the trick! I suppose this is a new header option? I also noticed that the server option
|
Glad that worked! Yes, www-root-path does the same thing as X-RStudio-Root-Path. We have a documentation update coming in the next release that will remove all of the guidance on using those directives to rewrite the location headers and cookie paths. Both options exist in 1.4 - Juliet Rose as well, and I think go back even a little further. |
@jeffvroom Looks to me like it's been a while and the docs aren't updated, e.g. https://docs.posit.co/ide/server-pro/access_and_security/running_with_a_proxy.html#nginx-configuration and https://docs.posit.co/ide/server-pro/1.4.1043-2/access-and-security.html#nginx-configuration - I just struggled for quite a while trying to rely on those, and only had success because of your rewrite-less solution here, as adapted to nginx by @DrMaphuse. |
@davidhunterwalsh - thanks for mentioning this. I only meant we planned to eliminate the |
I am in the same situation using kubernetes + nginx ingress + rstudio. |
When RStudio Server is hosted under a subdirectory using a reverse proxy (
https://website.name.com/rstudio
, for instance), many of the links will not redirect properly, namely the RStudio root,/auth-sign-in
, and/auth-sign-out
. Though the/auth-sign-in
and/auth-sign-out
issues can be solved with extra redirects, a successful sign in on the/auth-sign-in
page always redirects the user tohttps://website.name.com/
instead ofhttps://website.name.com/rstudio
like it should.Been looking to post this issue for a really long time (glad you guys finally have a public issue tracker) - it's confirmed to happen on all recent versions of both RStudio Server Open Source Edition and RStudio Server Pro on CentOS 7.
The text was updated successfully, but these errors were encountered: