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

时间:2022-08-26 23:49:06

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

我在ubuntu14上安装了RStudio Server v0.98.507和闪亮的服务器v1.1.0.10000。

my rstudio proxy setting on nginx default

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

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

that' my shiny server setting at /etc/shiny-server/shiny-server.conf

那是我的闪亮服务器设置在/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;
      }
    }

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

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

library(shiny)
runExample("01_hello")

when RStudio complier prompt

当RStudio依从者提示

Listening on http://'127.0.0.1':7146

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

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. 

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

但是,当我移除nginx默认的RStudio的代理旁路时。

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

it can run the shiny application from RStudio.

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

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.

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

1 个解决方案

#1


6  

RStudio complier prompt

RStudio依从者提示

Listening on http://'127.0.0.1':7146

监听http:// 127.0.0.1:7146

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

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

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

404错误消息表示路径没有找到。

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

要更直接地回答这个问题,请查看这里:http://table1.org/settingupan -ubuntu-server-with-nginx- - - -applications。

That page gives the nginx siteconf file to read:

该页面提供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/;
    }
}

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:

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

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

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

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

#1


6  

RStudio complier prompt

RStudio依从者提示

Listening on http://'127.0.0.1':7146

监听http:// 127.0.0.1:7146

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

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

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

404错误消息表示路径没有找到。

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

要更直接地回答这个问题,请查看这里:http://table1.org/settingupan -ubuntu-server-with-nginx- - - -applications。

That page gives the nginx siteconf file to read:

该页面提供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/;
    }
}

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:

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

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

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

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