本文介绍了Rstudio和闪亮的服务器代理设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

i have installed RStudio Server v0.98.507 and Shiny Server v1.1.0.10000 on my ubuntu14

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

my rstudio proxy setting on nginx default

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,但是,当我调用一个诸如此类的闪亮示例时

i can run both rstudio and shiny-server, however, when i call a shiny example such as

library(shiny)
runExample("01_hello")

RStudio编译器提示时

when RStudio complier prompt

Listening on http://'127.0.0.1':7146

URL返回无效响应,此处显示的是我的Chrome浏览器

the url return a invalid response and here the console on my chrome shown

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的代理绕过时

However, when i remove the proxy bypass of the RStudio in nginx default to

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

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

it can run the shiny application from RStudio.

我的问题是我该如何配置RStudio和Shiny服务器,这样我就可以删除:8787来运行rstudio和:3838来运行闪亮服务器.

My question is how could i config the RStudio and Shiny server so i could remove :8787 to run the rstudio and :3838 to run the shiny server.

推荐答案

Listening on http://'127.0.0.1':7146

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

Doesn't this mean that you should be passing the proxied request to 7146 rather than 8787?

404错误消息表明找不到该路径.

The 404 error message indicates that the path isn't found.

要直接回答该问题,请查看此处: http://table1.org/setting-up-an-ubuntu-server-with-nginx-up-to-run-shiny-applications .

To answer the question more directly, look here: http://table1.org/setting-up-an-ubuntu-server-with-nginx-up-to-run-shiny-applications.

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

That page gives the nginx siteconf file to read:

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对其进行代理.由于要在子目录中运行它,因此您可以使用以下代码:

So, you should be able to run your shiny server without having to proxy it through RStudio. Since you want to run it in a sub directory, you might be able to use this code:

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地址.

If that doesn't work, try changing out localhost for 127.0.0.1 or the actual ip address.

这篇关于Rstudio和闪亮的服务器代理设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-06 12:51