You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Shiny Server开源版HTTPS访问异常问题求助

解决方案步骤

1. 配置Apache反向代理(核心解决HTTPS访问问题)

Shiny Server默认不支持直接HTTPS访问,必须通过Apache的443端口做反向代理,把HTTPS请求转发到Shiny的3838端口。在ssl.conf的<VirtualHost *:443>块内添加以下配置:

# 禁用正向代理
ProxyRequests Off
# 允许本地代理访问
<Proxy *>
    Require all granted
</Proxy>
# 转发常规Shiny请求到3838端口
ProxyPass /shiny http://localhost:3838 retry=0
ProxyPassReverse /shiny http://localhost:3838
# 处理Shiny的WebSocket连接(交互功能必需)
ProxyPass /shiny/websocket ws://localhost:3838/websocket
ProxyPassReverse /shiny/websocket ws://localhost:3838/websocket
# 保留请求主机头信息
ProxyPreserveHost On

配置完成后重启Apache:systemctl restart httpd

之后通过https://ier1.tums.ac.ir/shiny访问Shiny应用,无需附加3838端口。

2. 调整防火墙与端口策略

  • 校外502错误大概率是3838端口未对外网开放,且校方虚拟服务器可能有硬件防火墙/安全组限制。需设置仅允许本地Apache服务(127.0.0.1)访问3838端口,对外网关闭该端口(更安全且避免直接访问冲突)。
  • 本地服务器防火墙(以firewalld为例)配置:
    # 添加本地访问3838端口的规则
    firewall-cmd --add-rich-rule='rule family="ipv4" source address="127.0.0.1" port port="3838" protocol="tcp" accept' --permanent
    # 重启防火墙生效
    firewall-cmd --reload
    

3. 确认Shiny Server监听设置

打开shiny-server.conf,确保server块的listen指令监听所有地址(或至少允许本地Apache访问):

server {
  listen 3838 0.0.0.0;
  # 其他原有配置...
}

重启Shiny Server:systemctl restart shiny-server

4. 排查SELinux与权限问题

如果配置后仍无法访问,检查SELinux限制:

# 允许Apache发起网络连接(反向代理必需)
setsebool -P httpd_can_network_connect on

同时确认Shiny应用目录的权限,确保Apache或Shiny运行用户拥有读取权限。

内容的提问来源于stack exchange,提问作者Mahdi Hadi

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.03 03:03:22