cockpit - 通过 Apache 反向代理代理驾驶舱
问题描述
我正在尝试使用 Apache 代理 cockpit[1],
它打开登录界面,但是登录后我得到一个空白屏幕,没有错误,什么都没有。在 devtools 中我发现了一个 ws 错误Error during WebSocket handshake: Unexpected response code: 400
cockpit-ws 守护进程在它的日志中输出这个
cockpit-ws[14523]: received invalid or missing Upgrade header: (null)
cockpit-ws[14523]: Received invalid handshake request from the client
cockpit-ws[14523]: WebSocket from 192.168.123.2 for session closed
我在 Centos7 上运行 cockpit 195
这里是相关的配置部分
ProxyPreserveHost On
ProxyRequests Off
# allow for upgrading to websockets
RewriteEngine On
RewriteCond %{HTTP:UPGRADE} ^WebSocket$ [NC]
RewriteCond %{HTTP:CONNECTION} ^Upgrade$ [NC]
RewriteRule .* ws://192.168.123.2:9090/%{REQUEST_URI} [P]
# Proxy to your local cockpit instance
ProxyPass / http://192.168.123.2:9090/
ProxyPassReverse / http://192.168.123.2:9090/
是的,我没有使用我知道的虚拟主机,我试图让它在/cockpit
url 上工作,但这是另一个问题
这是/etc/cockpit/cockpit.conf
[WebService]
Origins = https://192.168.123.2:9090 wss://192.168.123.2:9090 http://192.168.123.2 ws://192.168.123.2
ProtocolHeader = X-Forwarded-Proto
AllowUnencrypted = true
解决方案
有同样的问题,我忘了启用 proxy_wstunnel 模块。
sudo a2enmod proxy proxy_wstunnel proxy_http ssl rewrite
此处描述了整个 Apache 代理设置 https://github.com/cockpit-project/cockpit/wiki/Proxying-Cockpit-over-Apache-with-LetsEncrypt
推荐阅读
- swift - 如何从 HealthKit 中检索今天的正念记录?
- java - 使用大量工件组织 Maven 项目的方法
- java - 了解HashMap#resize函数细节
- python - for循环python中的MemoryError
- if-statement - Googlescript 'if' question - 只做两个任务之一
- c++ - 在序列中找到最小奇数和最大偶数
- php - 为什么 Bit-Wasp 使用 PrivateKeyFactory::fromWif PHP 会产生不推荐使用的错误
- django - 姜戈。休息框架。如何在 XML 中添加对象 ID?
- css - 导航栏上的下拉菜单位于其他组件下方
- go - 搜索一个网络是否包含在另一个网络中的功能