Nginx 反向代理上的 rstudio-server

Nginx 反向代理上的 rstudio-server

我在本地运行一个服务,rstudio-server。可以在我的机器本地IP,端口8787上访问此服务。

现在,我想通过以下地址从我的服务器访问此服务:rstudio.example.com(已完成 A 条目)。

我用Nginx并创建了这个块:

server {
    listen 80;
    listen 443 ssl;
    server_name rstudio.example.com;
    root /usr/lib64/rstudio-server/www;
    include /etc/nginx/ssl/rstudio.ssl.conf;


location / {
    # rewrite ^/rstudio/(.*)$ /$1 break;
    #proxy_pass http://192.168.1.94:8787;
    proxy_pass http://unix:/run/rstudio-server/rstudio-server.sock;
    #proxy_redirect http://192.168.1.94:8787/ rstudio.myexample.com;
    proxy_redirect http://unix:/run/rstudio-server/rstudio-server.sock rstudio.myexample.com;
    #proxy_http_version 1.1;
    #proxy_set_header Upgrade $http_upgrade;
    #proxy_set_header Connection "upgrade"; 
    }

我自愿评论了我尝试过的所有选项。所有解决方案都无法让我连接到 example.com 上的服务。我在日志中看到的只有:

*5 epoll_wait() reported that client prematurely closed connection, so upstream connection is closed too while sending request to upstream

通过谷歌搜索这个错误我并没有找到明确的答案。

我在 Nginx 上的代理设置中哪里错了?感谢您的提示。

答案1

尝试这个:

http {

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

  server {
    listen 80;
    listen 443 ssl;
    server_name rstudio.example.com;
    root /usr/lib64/rstudio-server/www;
    include /etc/nginx/ssl/rstudio.ssl.conf;

    location / {
      proxy_pass http://192.168.1.94:8787;
      proxy_redirect http://192.168.1.94:8787/ $scheme://$host/;
      proxy_http_version 1.1;
      proxy_set_header Upgrade $http_upgrade;
      proxy_set_header Connection $connection_upgrade;
      proxy_read_timeout 20d;
    }
  }
}

相关内容