Rstudio和闪亮的服务器代理设置

 涿州雨嫣舞蹈培训中心_144 发布于 2023-01-11 14:55

我在我的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

url返回无效响应,此处显示我的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运行闪亮的服务器.

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

    如果还是不行,请尝试更改了localhost127.0.0.1或实际的IP地址.

    2023-01-11 14:58 回答
撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有