闪亮服务器 - 托管其他应用程序时出现问题
Shiny Server - problem hosting an additional app
我目前有一个实时网站,目前通过闪亮的服务器托管一个应用程序。一段时间以来,我一直在尝试弄清楚如何托管一个额外的应用程序作为域的扩展。如果我的网站是托管主应用程序的 "www.mywebsite.com",我想在 "www.mywebsite.com/SecondApp" 托管另一个应用程序。我已经通读了我找到的所有文档,看来这应该可以通过更改 /etc/shiny-server 目录中的 shiny-server.conf
文件来实现。根据 Shiny Server Admin Guide 中的第 2.2.2 节位置,更新配置文件似乎应该实现这一点:
server {
...
location /SecondApp {
app_dir /srv/shiny-server/SecondApp
}
...
}
我已将相应的 ui.R 和 server.R 脚本添加到 /srv/shiny-server/SecondApp 目录,并且我可以 运行 在我的浏览器中本地 运行
MYIP:3838/SecondApp/
但是当我更新 shiny-server.conf
脚本并重新启动 shiny 服务器时,"www.mywebsite.com/SecondApp" returns 一个显示 "Not Found" 的空白屏幕。我没有尝试为此应用程序设置新端口,但根据我在文档和各种 github 脚本中看到的所有内容,似乎此配置应该有效。我错过了什么?我的完整配置文件如下所示:
# 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;
}
}
这里的问题是端口吗?看起来 3838 是默认的闪亮服务器端口,据我所知,其他人有时会通过自己的端口将其更新为 运行。但正如我所提到的,我 运行 当前的站点完全可以正常工作。我也尝试通过添加一个额外的位置来更新 /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";
}
...
}
除非这与我的实际域有关,否则我不知所措。有任何想法吗?谢谢!
如果您在 /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";
}
然后您可以获取 shiny-server 配置来控制在什么扩展程序上提供什么应用程序。下面的配置应该适合你。
# 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;
}
}
}
记得重启 nginx 和 shiny-server 以使更改生效。
sudo systemctl restart nginx
sudo systemctl restart shiny-server
我目前有一个实时网站,目前通过闪亮的服务器托管一个应用程序。一段时间以来,我一直在尝试弄清楚如何托管一个额外的应用程序作为域的扩展。如果我的网站是托管主应用程序的 "www.mywebsite.com",我想在 "www.mywebsite.com/SecondApp" 托管另一个应用程序。我已经通读了我找到的所有文档,看来这应该可以通过更改 /etc/shiny-server 目录中的 shiny-server.conf
文件来实现。根据 Shiny Server Admin Guide 中的第 2.2.2 节位置,更新配置文件似乎应该实现这一点:
server {
...
location /SecondApp {
app_dir /srv/shiny-server/SecondApp
}
...
}
我已将相应的 ui.R 和 server.R 脚本添加到 /srv/shiny-server/SecondApp 目录,并且我可以 运行 在我的浏览器中本地 运行
MYIP:3838/SecondApp/
但是当我更新 shiny-server.conf
脚本并重新启动 shiny 服务器时,"www.mywebsite.com/SecondApp" returns 一个显示 "Not Found" 的空白屏幕。我没有尝试为此应用程序设置新端口,但根据我在文档和各种 github 脚本中看到的所有内容,似乎此配置应该有效。我错过了什么?我的完整配置文件如下所示:
# 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;
}
}
这里的问题是端口吗?看起来 3838 是默认的闪亮服务器端口,据我所知,其他人有时会通过自己的端口将其更新为 运行。但正如我所提到的,我 运行 当前的站点完全可以正常工作。我也尝试通过添加一个额外的位置来更新 /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";
}
...
}
除非这与我的实际域有关,否则我不知所措。有任何想法吗?谢谢!
如果您在 /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";
}
然后您可以获取 shiny-server 配置来控制在什么扩展程序上提供什么应用程序。下面的配置应该适合你。
# 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;
}
}
}
记得重启 nginx 和 shiny-server 以使更改生效。
sudo systemctl restart nginx
sudo systemctl restart shiny-server