apache - Apache2 反向代理和 websocks
问题描述
我正在尝试通过以下方式允许我的反向代理中的 websocks:
<Location "/monitor">
ProxyPreserveHost On
RequestHeader set X-Forwarded-Proto https
RequestHeader set X-Forwarded-Port 443
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/monitor/notify [NC]
RewriteCond %{QUERY_STRING} transport=websocket [NC]
RewriteRule ^/monitor/notify/(.*) wss://localhost:8001/monitor/notify/$1 [P,L]
ProxyPass http://localhost:8001/monitor
ProxyPassReverse http://localhost:8001/monitor
</Location>
但我收到了这个错误:
VM690:149 WebSocket connection to 'wss://MY.HOST/monitor/notify/516/q7pqnqdz/websocket' failed: Error during WebSocket handshake: Unexpected response code: 400
我做错了什么?
解决方案
解决了这个问题:
RewriteEngine On
RewriteCond %{HTTP:Connection} Upgrade [NC]
RewriteCond %{HTTP:Upgrade} websocket [NC]
RewriteRule /monitor/(.*) ws://127.0.0.1:8001/monitor/$1 [P,L]
推荐阅读
- reactjs - RN 在 0.57.3 中禁用了样式道具检查吗?
- mysql - 按日期时间范围分组 - MySql
- ios - 有没有办法播种 Swift 4.2 随机数生成器
- ruby-on-rails - 在 Rails 引擎上导入引导程序
- python - 修复来自 API 的 JSON 输出
- docker - Heroku-cli:尝试部署 NodeJS 应用程序的 docker 映像后,docker run 以 127 退出
- r - 在 R 中合并两个数据帧时得到重复的行,我应该合并还是加入这两个数据帧?
- dns - 如何将 DNS 指向动态 IP 地址?
- python - 如何使用 groupby 计算先前在数据框中使用的产品数量?
- php - 在 GET 请求中为 & 创建不同的符号