简体   繁体   English

WebSocket握手期间出错:缺少“升级”标头(Apache 2.4 + mod_proxy_wstunnel)

[英]Error during WebSocket handshake: 'Upgrade' header is missing (Apache 2.4 + mod_proxy_wstunnel)

I have Apache 2.4 running on the server and have setup a subdomain to handle my Node.JS web app which also uses websockets. 我在服务器上运行了Apache 2.4,并设置了一个子域来处理我的Node.JS Web应用程序,该应用程序也使用websockets。

My Apache site config for this is: 我的Apache站点配置是:

<VirtualHost *:80> 
  ProxyPreserveHost On
  ProxyRequests Off
  ServerName ws.mysite.io
  ProxyPass /ws/ ws://1.2.3.5:6789/
  ProxyPassReverse /ws/ ws://1.2.3.5:6789/
  ProxyPass / http://1.2.3.5:6789/
  ProxyPassReverse / http://1.2.3.5:6789/
</VirtualHost> 

So that when users come to http://ws.mysite.io/ - they get served the html from my node.js app (using express) and the html has a javascript part communicating back with the node.js app via websocket on ws.mysite.io/ws/ which is "tunneled" to ws://1.2.3.5:6789/ . 因此,当用户访问http://ws.mysite.io/ - 他们从我的node.js应用程序(使用快递)获得html,并且html有一个javascript部分通过websocket与node.js应用程序进行通信ws.mysite.io/ws/是“隧道”到ws://1.2.3.5:6789/

I get a situation where on a home wifi - all works. 我得到一个家庭无线网络的情况 - 一切正常。 No problems. 没问题。

At work, we do have firewall, proxy... but i don't know exact limitations or blocks, but what happens is that when i open http://ws.mysite.io/ I get in Chrome console: 在工作中,我们确实有防火墙,代理......但我不知道确切的限制或阻止,但是当我打开http://ws.mysite.io/我会进入Chrome控制台:

WebSocket connection to 'ws://ws.mysite.io/ws/' failed: Error during WebSocket handshake: 'Upgrade' header is missing

Is this due to the work proxy "cutting" something off? 这是由于工作代理“削减”了一些东西吗? Is there any chance to set up a "bullet-proof" tunnel to overcome things like that? 有没有机会建立一个“防弹”隧道来克服这样的事情?

As far as I know, you don't need this line: 据我所知,你不需要这一行:

ProxyPassReverse /ws/ ws://1.2.3.5:6789/ ProxyPassReverse / ws / ws://1.2.3.5:6789 /

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在不使用第三方 API 的情况下使用 Apache 的 mod_proxy_wstunnel 连接到 PHP - Connecting to PHP using Apache's mod_proxy_wstunnel without using 3rd Party APIs WebSocket握手期间出错:PHP的“Sec-WebSocket-Accept”标头值不正确 - Error during WebSocket handshake: Incorrect 'Sec-WebSocket-Accept' header value with PHP 无法托管WebSocket服务器-握手期间出错 - Cannot host WebSocket Server - error during handshake chrome在WebSocket握手期间获取新错误 - chrome getting new Error during WebSocket handshake Websocket:WebSocket握手期间出错:意外的响应代码:504 - Websocket : Error during WebSocket handshake: Unexpected response code: 504 Websocket - WebSocket 握手期间出错:意外的响应代码:404 - Websocket - Error during WebSocket handshake: Unexpected response code: 404 WebSocket 连接失败。 WebSocket 握手期间出错 - socketjs - WebSocket connection failed. Error during WebSocket handshake - socketjs Websocket握手代码期间无法连接signalR错误:400 - failed to connect signalR error during websocket handshake code : 400 Sailsjs:WebSocket握手期间出错:意外的响应代码:400 - Sailsjs: Error during WebSocket handshake: Unexpected response code: 400 WebSocket 握手期间出错:意外的响应代码:500 - Error during WebSocket handshake: Unexpected response code: 500
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM