Connection refused - When running app

Hi,

I have updated my r studio recently to 2022.07.2 Build 576 , I am able to successfully launch my r studio, but when I am trying to run a simple hello world I am getting Connection refused message in the browser, and in network tab I can see 500 error

Nginx file-
server {
listen 8080 ssl;

  location / {
        proxy_pass http://localhost:8787;  
        proxy_redirect $scheme://$host:$server_port $scheme://test.com/;
        proxy_set_header X-RStudio-Request $scheme://$host:$server_port$request_uri;
        proxy_set_header X-RStudio-Root-Path /svc/rstudio/4335456;
        proxy_set_header Host $host:$server_port;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection $connection_upgrade;
        proxy_read_timeout 20d;
        proxy_buffering off;
    }

}

Your configuration differs from the one in the documentation as RStudio Workbench Administration Guide - 30  Running with a Proxy. In particular the proxy_redirect and the first two proxy_set_header are not in the docs. Do you have the map code outside of the server section?

@rstub This is my complete file

pid "/home/docker/nginx/tmp/nginx.pid";
error_log "/home/docker/nginx/log/error.log";

events { }

http {
    map $http_upgrade $connection_upgrade {
        default upgrade;
        ''      close;
    }

    client_body_temp_path  "/home/docker/nginx/tmp/client_body" 1 2;
    proxy_temp_path "/home/docker/nginx/tmp/proxy" 1 2;
    fastcgi_temp_path "/home/docker/nginx/tmp/fastcgi" 1 2;
    scgi_temp_path "/home/docker/nginx/tmp/scgi" 1 2;
    uwsgi_temp_path "/home/docker/nginx/tmp/uwsgi" 1 2;
    access_log  "/home/docker/nginx/log/access.log";
    error_log "/home/docker/nginx/log/error.log";

    client_max_body_size 1024m;

    ssl_certificate /etc/ssl/rstudio/server.crt;
    ssl_certificate_key /etc/ssl/rstudio/server.key;
    ssl_ciphers Ett;
    ssl_protocols TLSv1.2;

    server {
        listen 8080 ssl;

 		      location / {
            proxy_pass http://localhost:8787;         
            proxy_redirect $scheme://$host:$server_port https://test.com;

            proxy_set_header X-RStudio-Request $scheme://$host:$server_port$request_uri;
            proxy_set_header X-RStudio-Root-Path /svc/rstudio/1111;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection $connection_upgrade;
            proxy_read_timeout 20d;
            proxy_buffering off;
        }
        location /nginx_status {
 	        stub_status on;
            access_log off;
 	        allow 127.0.0.1;	#only allow requests from localhost
 	        deny all;		#deny all other hosts
        }
    }
}

The above lines have no analogue in the documentation. Can you delete them and try again?

@rstub ,
after removing above lines I am getting this
in header this url is forming

I have also added proxy_set_header Host $host:$server_port;

Location:

https://https:/auth-sign-in?appUri=%2F

This content is blocked. Contact the site owner to fix the issue.

@rstub can u please help here

Currently I do not see where this duplicated "https" in the location might come from. Can you provide a reproducible example, e.g. using Docker files?

@rstub

I was using rstudio version 1.2.1335 with following nginx.conf

    location / {
        proxy_pass http://localhost:8787;
        proxy_redirect http://localhost:8787/ $scheme://$http_host/;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection $connection_upgrade;
        proxy_read_timeout 20d;
        proxy_buffering off;
    }

and above version was working very smoothly with this conf,
But now when we upgraded to r sudio version 2022.07.2+576 it started giving issue

https://localhost:8787/auth-sign-in?appUri=%2F

with status code 302

https://localhost:8787/auth-sign-in?appUri=%2F (“frame-src”).
pfa screenshot -

I have tried to reproduce the issue using a minimal nginx configuration that follows our documentation:

$ cat docker-compose.yml
services:
    rstudio:
        image: rocker/rstudio
        environment:
        - PASSWORD=rstudio12

    proxy:
        image: nginx
        volumes:
        - ./nginx.conf:/etc/nginx/nginx.conf
        ports:
        - "80:80"
$ cat nginx.conf
events { }

http {
    map $http_upgrade $connection_upgrade {
        default upgrade;
        ''      close;
    }

    server {
        listen 80;

        location / {
            proxy_pass http://rstudio:8787;         
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection $connection_upgrade;
	    proxy_set_header Host $host:$server_port;
            proxy_read_timeout 20d;
        }
    }	
}
$ docker-compose -d

So far everything is working as expected. Can you maybe use this configuration and change it such that your issue is reproduced?

why have u used rstudio:8787, isn't it should be proxy_pass http://localhost:8787;

With docker-compose the proxy server runs on a different "node" than RStudio Server. The former is called proxy and the latter is called rstudio.

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

If you have a query related to it or one of the replies, start a new topic and refer back with a link.