简体   繁体   English

Shiny Server - 托管其他应用程序的问题

[英]Shiny Server - problem hosting an additional app

I currently have a live website that hosts one app at the moment through shiny server. 我目前有一个实时网站,通过闪亮的服务器托管一个应用程序。 I've been trying for some time to figure out how to host an additional app as an extension of the domain. 我已经尝试了一段时间来弄清楚如何托管额外的应用程序作为域的扩展。 If my website is "www.mywebsite.com", which hosts the main app, I want to host another app at "www.mywebsite.com/SecondApp". 如果我的网站是“www.mywebsite.com”,它主持主应用程序,我想在“www.mywebsite.com/SecondApp”上托管另一个应用程序。 I've read through all of the documentation that I've found, and it appears this should be possible by altering the shiny-server.conf file in the /etc/shiny-server directory. 我已经阅读了我找到的所有文档,看起来应该可以通过更改/ etc / shiny-server目录中的shiny-server.conf文件来实现。 Per section 2.2.2 Location in the Shiny Server Admin Guide it would appear that updating the configuration file as so should achieve this: 根据Shiny Server管理员指南中的2.2.2位置,似乎更新配置文件应该实现此目的:

server {
...
  location /SecondApp {
  app_dir /srv/shiny-server/SecondApp
  }
...
}

I've added the respective ui.R and server.R scripts to the /srv/shiny-server/SecondApp directory, and I am able to run this locally in my browser browser at 我已将相应的ui.R和server.R脚本添加到/ srv / shiny-server / SecondApp目录,我可以在浏览器浏览器中本地运行

MYIP:3838/SecondApp/ 

But when I update the shiny-server.conf script and restart shiny server, "www.mywebsite.com/SecondApp" returns a blank screen that shows "Not Found". 但是当我更新shiny-server.conf脚本并重新启动闪亮服务器时,“www.mywebsite.com/SecondApp”会返回一个显示“未找到”的空白屏幕。 I haven't tried setting up a new port for this app, but from everything I've seen in the documentation and various github scripts, it seems this configuration should work. 我没有尝试为这个应用程序设置一个新端口,但是从我在文档和各种github脚本中看到的所有东西,似乎这个配置应该工作。 What am I missing? 我错过了什么? My full configuration file looks like: 我的完整配置文件如下所示:

# Instruct Shiny Server to run applications as the user "shiny"
run_as shiny;

# Define a server that listens on port 3838
server {
  listen 3838;

    log_dir /var/log/shiny-server;

  # Add extension
  location /SecondApp {
    app_dir /srv/shiny-server/SecondApp;
  }

  # Define a location at the base URL
  location / {

    # Host the directory of Shiny Apps stored in this directory
    site_dir /srv/shiny-server;

    # Log all Shiny output to files in this directory
    #log_dir /var/log/shiny-server;

    # When a user visits the base URL rather than a particular application,
    # an index of the applications available in this directory will be shown.

    directory_index on;
  }
}

Is the issue here the port? 问题出在港口吗? It appears 3838 is the default shiny server port, and from what I've seen it appears others sometimes update this to run through its own port. 看来3838是默认的闪亮服务器端口,从我看到的其他人有时会更新它以通过自己的端口运行。 But as I mentioned, the current site I run works completely fine. 但正如我所提到的,我运行的当前网站完全正常。 I've also tried updating the nginx configuration file in the /etc/nginx/sites-enabled directory by adding an additional location as so, but this doesn't help: 我也尝试通过添加一个额外的位置来更新/ etc / nginx / sites-enabled目录中的nginx配置文件,但是这没有帮助:

server {
...
location /SecondApp {
    proxy_pass http://MYIP:3838/SecondApp/;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
  }
...
}

Unless this has to do with my actual domain, I'm at a loss. 除非这与我的实际域名有关,否则我不知所措。 Any ideas? 有任何想法吗? Thanks! 谢谢!

If you configure nginx config in /etc/nginx/sites-enabled/ to proxy all traffic to port 3838 like so: 如果在/etc/nginx/sites-enabled/配置nginx配置,则将所有流量代理到端口3838,如下所示:

location / {
         proxy_pass http://127.0.0.1:3838/;
         proxy_http_version 1.1;
         proxy_set_header Upgrade $http_upgrade;
         proxy_set_header Connection "upgrade";
}

You can then get the shiny-server config to control what apps are served at what extension. 然后,您可以获取闪亮的服务器配置,以控制在哪个扩展程序中提供的应用程序。 The config below should work for you. 下面的配置应该适合你。

# Instruct Shiny Server to run applications as the user "shiny"
run_as shiny;

# Define a server that listens on port 3838
server {
  listen 3838;

  # Define a location at the base URL
  location / {

    # Host your main app at the base URL
    app_dir /srv/shiny-server/MainApp;

    # Log all Shiny output to files in this directory
    log_dir /var/log/shiny-server;

    # define a location within the base location
    # to serve your second app
    location /SecondApp {
      app_dir /srv/shiny-server/SecondApp;
    }
  }

}

Remember to restart nginx and shiny-server for changes to take effect. 请记住重新启动nginx和shiny-server以使更改生效。

sudo systemctl restart nginx
sudo systemctl restart shiny-server

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM