您好我正在尝试使用反向代理设置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容器上运行
答案 0 :(得分:-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;
}