我正在运行 Ubuntu、Apache、mod_proxy_wstunnel(已启用)、Shiny-Server 和 R。我已设置 shiny-server 以在本地进行监听,并设置 Apache 以代理 shiny-server 的请求。我还在我的 Apache 配置中为整个域设置了基本授权。
除了当 shiny-server 应用程序尝试发出 Web Socket 请求时,其他一切都正常。我收到以下错误。
WebSocket connection to 'ws://xxxxxx.com/shiny-application/__sockjs__/407/ercpnzw1/websocket' failed: Error during WebSocket handshake: Unexpected response code: 401
我通常只会添加 Web Socket 的确切 URL,但是这个 sock.js URL 是动态的,并且总是在变化。
有没有办法使用 apache 配置中的正则表达式来解决此问题?
答案1
为了修复此问题,最有可能是由 Shiny-server 和 Apache 的反向代理引起的。添加 disable_websockets true; 如下所示。**注意:** 这似乎仅适用于较新版本的 Shiny-Server(我相信是 Shiny Server Professional v1.2.0)。
# Define the user we should use when spawning R Shiny processes
run_as shiny;
disable_websockets true;
# 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 / {
#### PRO ONLY ####
# Only up tp 20 connections per Shiny process and at most 3 Shiny processes
# per application. Proactively spawn a new process when our processes reach
# 90% capacity.
utilization_scheduler 20 .9 3;
#### END PRO ONLY ####
# 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;
}
}