【问题标题】:Is it possible to deploy multiple shiny apps to one server using NGINX?是否可以使用 NGINX 将多个闪亮的应用程序部署到一台服务器?
【发布时间】:2020-10-23 21:10:12
【问题描述】:

理想情况下,如果我有两个应用程序,我希望一台服务器能够同时为这两个应用程序提供服务。

目前我的配置文件支持一个部署在 3838 端口的闪亮应用程序。

是否可以在另一个端口上运行另一个闪亮服务器实例,以便我的一台服务器可以托管两个不同的应用程序?

如果是这样,如果我尝试完成此操作,配置文件会是什么样子?

提前谢谢你

【问题讨论】:

    标签: r nginx shiny shiny-server


    【解决方案1】:

    如果我理解正确,您不希望另一台服务器而是同一台服务器上的另一个应用程序。

    不要将两个应用程序在不同端口上侦听与一个服务器和两个应用程序只在一个端口上侦听混淆,因为通常应该只有一个服务器,正如你所说,侦听端口 3838,根据 URL,将提供一个或另一个应用程序。

    如果您已经有一个/etc/shiny-server/shiny-server.conf 文件,您应该只添加指令以便服务器将请求发送到一个应用程序而不是另一个应用程序。

    您应该使用以下规则编辑该文件:

    server {
      ...
      # When accessing yourServer:3838/specialApp1
      location /specialApp1 {
        # Nginx will send the request to this application
        app_dir /srv/shiny-server/myApp
      }
      
      # When accessing yourServer:3838/specialApp2
      location /specialApp2 {
        # Nginx will send the request to this application
        app_dir /srv/shiny-server/myApp2
      }
    ...
    }
    

    希望对您有所帮助!如果没有,请发布您的/etc/shiny-server/shiny-server.conf 文件!

    【讨论】:

      【解决方案2】:

      您需要单独的服务器实例,还是需要为两个应用程序提供服务?

      在第一次安装 Shiny Server 时,第一页会告诉您如何添加多个应用程序。您应该能够简单地将它们放在单独的文件夹中,例如/srv/shiny-server/app1../app2

      Configuration Reference 中也对此进行了描述,位于 2.2.2 位置

      server {
        ...
        # Define the location '/specialApp'
        location /specialApp {
          # Run this location in 'app_dir' mode, which will host a single Shiny
          # Application available at '/srv/shiny-server/myApp'
          app_dir /srv/shiny-server/myApp
        }
        
        # Define the location '/otherApps'
        location /otherApps {
          # Run this location in 'site_dir' mode, which hosts the entire directory
          # tree at '/srv/shiny-server/apps'
          site_dir /srv/shiny-server/apps;
        }
      ...
      }
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2018-08-20
        • 2016-10-16
        • 2014-08-09
        • 1970-01-01
        • 2017-09-06
        • 2023-04-09
        • 2016-12-28
        • 2018-12-04
        相关资源
        最近更新 更多