【问题标题】:Rstudio and shiny server proxy settingRstudio 和闪亮的服务器代理设置
【发布时间】:2014-07-26 10:47:07
【问题描述】:

我已经在我的 ubuntu14 上安装了 RStudio Server v0.98.507 和 Shiny Server v1.1.0.10000

我在 nginx 默认上的 rstudio 代理设置

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

这是我在 /etc/shiny-server/shiny-server.conf 上的闪亮服务器设置

    # Define the user we should use when spawning R Shiny processes
        run_as shiny;

    # Define a top-level server which will listen on a port
        server {
      # Instruct this server to listen on port 3838
      listen 3838;

          # Define the location available at the base URL
      location / {


        # Run this location in 'site_dir' mode, which hosts the entire directory
        # tree at '/srv/shiny-server'
        site_dir /srv/shiny-server;

        # Define where we should put the log files for this location
        log_dir /var/log/shiny-server;

        # Should we list the contents of a (non-Shiny-App) directory when the user 
        # visits the corresponding URL?
        directory_index on;
      }
    }

我可以同时运行 rstudio 和 shiny-server,但是,当我调用一个闪亮的例子时,例如

library(shiny)
runExample("01_hello")

当 RStudio 编译器提示时

Listening on http://'127.0.0.1':7146

网址返回无效响应,此处显示我的 chrome 上的控制台

WebSocket connection to 'ws://mydomain.com/rstudio/p/7146/websocket/' failed: Error during WebSocket handshake: Unexpected response code: 404 mydomaion.com/rstudio/p/7146/shared/shiny.js:507
WebSocket is already in CLOSING or CLOSED state. 

但是,当我在 nginx 默认 中删除 RStudio 的代理绕过时,

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

它可以从 RStudio 运行闪亮的应用程序。

我的问题是如何配置 RStudio 和 Shiny 服务器,以便我可以删除 :8787 来运行 rstudio 和 :3838 来运行 Shiny 服务器。

【问题讨论】:

    标签: nginx proxy rstudio shiny-server


    【解决方案1】:

    RStudio 编译器提示

    Listening on http://'127.0.0.1':7146

    这是否意味着您应该将代理请求传递给7146 而不是8787

    404 错误信息表示找不到路径。

    要更直接地回答问题,请看这里:http://table1.org/setting-up-an-ubuntu-server-with-nginx-up-to-run-shiny-applications

    该页面提供了要读取的 nginx siteconf 文件:

    server {
        listen 80;
        server_name shinyapp.domain.name;
    
        location / {
                proxy_pass http://server-ip-address:3838/shinyapp/;
                proxy_redirect http://server-ip-address:3838/ $scheme:$host/;
        }
    }
    

    因此,您应该能够运行闪亮的服务器,而无需通过 RStudio 代理它。由于您想在子目录中运行它,因此您可以使用以下代码:

    location /rstudio/ {
         rewrite ^/rstudio/(.*)$ /$1 break;
         proxy_pass http://localhost:3838;
         proxy_redirect http://localhost:3838/ $scheme://$host/rstudio/;
    }
    

    如果这不起作用,请尝试将 localhost 更改为 127.0.0.1 或实际 IP 地址。

    【讨论】:

    • 这确实很有帮助,但链接不再有效
    猜你喜欢
    • 2016-10-26
    • 2015-10-21
    • 2016-08-06
    • 2012-04-06
    • 2021-01-01
    • 2016-05-23
    • 1970-01-01
    • 2016-12-09
    • 2015-10-22
    相关资源
    最近更新 更多