【问题标题】:Nginx 502: Bad Gateway with rstudio serverNginx 502:带有 rstudio 服务器的错误网关
【发布时间】:2015-03-22 23:04:58
【问题描述】:

您好,我正在尝试使用反向代理设置 RStudio 服务器。

这是我的 Nginx 配置

user nginx;
worker_processes 1;

# Defines a file that will store the process ID of the main process.
pid /var/run/nginx.pid;

events {
  # Sets the maximum number of simultaneous connections that can be opened by a worker process.
  worker_connections 1024;
}

http {
  server {

    # Running port
    listen 80;

    # Proxying the connections
    location /rstudio/ {
      rewrite ^/rstudio/(.*)$ /$1 break;
      proxy_pass http://localhost:8787;
      proxy_redirect http://localhost:8787/ $scheme://$host/rstudio/;
    }
  }
}

不幸的是,我收到了 502: Bad Gateway 错误。你有什么主意吗? 据 netstat 报告,8787 已打开

tcp6       0      0 :::80                   :::*                    LISTEN      -
tcp6       0      0 :::8787                 :::*                    LISTEN      -

RStudio 和 nginx 在两个独立的 docker 容器上运行,这些容器都打开了端口

【问题讨论】:

  • 添加/删除斜线没有任何变化

标签: nginx docker rstudio


【解决方案1】:

在 Rstudio 网站上有一个操作文档,详细说明了如何使用 Nginx 或 Apache 反向代理。

https://support.rstudio.com/hc/en-us/articles/200552326-Running-RStudio-Server-with-a-Proxy

对于 nginx,它建议以下配置:-

http {

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

server {
  listen 80;


  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;
  }

【讨论】:

    猜你喜欢
    • 2019-09-20
    • 2016-07-29
    • 1970-01-01
    • 1970-01-01
    • 2015-04-07
    • 2019-12-04
    • 1970-01-01
    • 2020-06-29
    • 1970-01-01
    相关资源
    最近更新 更多