Rstudio redirects to localhost/auth-sign-in

System details

RStudio Edition : Server
RStudio Version : 1.1.447
OS Version : Ubuntu 16.04.4 LTS
R Version : 3.4.4

We using the rstudio-server with a nginx proxy-server. The Problem is, when calling the url of rstudio e.g. example/rstudio/ i will be redirected to localhost. If if call the url e.g. example/rstudio/auth-sign-in i get the login page and are able to login. After submitting the Credentials, i will be redirected to localhost again. But then when iam calling the URL example/rstudio, iam logged in and everything works fine.
The logout shows the same behavior and redirects to localhost.

Our vhost Configuration File looks like the example here support.rstudio.com/hc/en-us/articles/200552326-Running-RStudio-Server-with-a-Proxy

location /rstudio/ {
  rewrite ^/rstudio/(.*)$ /$1 break;
  proxy_pass localhost:8787;
  proxy_redirect localhost : 8787/ $scheme://$host/rstudio/;
  proxy_http_version 1.1;
  proxy_set_header Host url
  proxy_set_header Upgrade $http_upgrade;
  proxy_set_header Connection $connection_upgrade;
  proxy_read_timeout 20d;

}

The proxy_redirect localhost is a link, but i cant post it, because iam only allowed to post 2 links. I also set the host header, but then i get a 404 HTTP Error.

Any Ideas?

It looks like you found the right support article, but it seems you are having trouble with the proxy_pass and proxy_redirect configuration. Did you try using the configuration exactly as specified in the article?

location /rstudio/ {
      rewrite ^/rstudio/(.*)$ /$1 break;
      proxy_pass http://localhost:8787;
      proxy_redirect http://localhost:8787/ $scheme://$host/rstudio/;
      proxy_http_version 1.1;
      proxy_set_header Upgrade $http_upgrade;
      proxy_set_header Connection $connection_upgrade;
      proxy_read_timeout 20d;
    }

Hi,

the difference is, that we use 443 ssl and put the configuration in a vhost-file.

server {
    listen 443 ssl;
    listen [::]:443 ssl;
    include /etc/nginx/default.d/*.conf;

    access_log  /var/log/nginx/xxxx/access.log  main;

    ssl_certificate /etc/nginx/ssl/appsrv.pem;
    ssl_certificate_key /etc/nginx/ssl/key.pem;

    location /rstudio/ {
      rewrite ^/rstudio/(.*)$ /$1 break;
      proxy_pass Here_is_the_link with Port
      proxy_redirect Here_is_the_link with Port $scheme://$host/rstudio/;
      proxy_http_version 1.1;
      proxy_set_header Upgrade $http_upgrade;
      proxy_set_header Connection $connection_upgrade;
      proxy_read_timeout 20d;
    }
}

Apologies for the delay in responding to this. If you reply directly to my post or "@mention" me in response, it will be sure that I get a notification for the update.

In any case, it will be very tricky for us to help debug your implementation without your actual config file. If you need to mask values, is it possible that you do so with "realistic" values instead of Here_is_the_link with Port? In this case, you would need something like http://localhost:8787 or http://myurl:8787.

Also, you are missing a semicolon after proxy_pass, but again I'm not sure if this is a result of your masking values or not.

1 Like