简体   繁体   English

Apache:当需要HTTP 101时,Websocket通过代理返回HTTP 200

[英]Apache: Websocket returning HTTP 200 over proxy when needing HTTP 101

I'm attempting to run https://github.com/dynastic/place through an Apache proxy. 我正在尝试通过Apache代理运行https://github.com/dynastic/place Everything works except a websocket returning HTTP 200 instead of HTTP 101, which causes errors in both Chrome and Firefox. 除了返回HTTP 200而不是HTTP 101的websocket之外,其他所有方法都有效,这会在Chrome和Firefox中导致错误。 How can I rectify this problem? 如何解决此问题?

The Apache 2.4 proxy is running through a FreeNAS jail [192.168.0.2] and the repo (Place) is running on a Debian VM [192.168.0.3]. Apache 2.4代理正在通过FreeNAS监狱[192.168.0.2]运行,仓库(Place)在Debian VM [192.168.0.3]上运行。 The proxy begins at subdomain.domain.com and routes to 192.168.0.3:3000. 代理从subdomain.domain.com开始,并路由到192.168.0.3:3000。 Everything works perfectly except a websocket that returns HTTP 101 when connecting to http://192.168.0.3:3000 but returns an HTTP 200 when connecting through https://subdomain.domain.com . 除websocket可以正常运行外,它在连接到http://192.168.0.3:3000时返回HTTP 101,但在通过https://subdomain.domain.com连接时返回HTTP 200。

I have config files all over the place that I can provide if needed, but here is the main config file. 我在需要时可以提供的所有地方都有配置文件,但这是主要的配置文件。 SSL configuration is defined in other files and SSL does not seem to be the problem as I have tried on HTTP. SSL配置是在其他文件中定义的,并且SSL似乎不是我在HTTP上尝试过的问题。

sites-enabled/place.conf : sites-enabled/place.conf

<VirtualHost *:443>
ServerName subdomain.domain.com

ErrorLog /path/to/error.log
CustomLog /path/to/access.log combined

SSLProxyEngine On
ProxyRequests Off
ProxyPreserveHost On
<Location />
        ProxyPass http://192.168.0.3:3000/
        ProxyPassReverse http://192.168.0.3:3000/
</Location>
RequestHeader set Connection "Upgrade"

RewriteEngine on
RewriteCond %{HTTP:UPGRADE} ^WebSocket$ [NC]
RewriteCond %{HTTP:CONNECTION} ^Upgrade$ [NC]
RewriteRule .* wss://192.168.0.3:3000%{REQUEST_URI} [P]



</VirtualHost>

In the Readme.md on the Place GitHub repo, it shows an Nginx repository which in theory returns the correct HTTP 101 code (I tested locally). 在Place GitHub存储库上的Readme.md中,它显示了一个Nginx存储库,该存储库理论上返回正确的HTTP 101代码(我在本地测试)。 Apache incorrectly returns an HTTP 200 code. Apache错误地返回HTTP 200代码。 I currently use Apache for other services on the server so sticking with that would be nice but at this point I may have to look for other options. 我目前将Apache用于服务器上的其他服务,因此坚持使用会很不错,但此时我可能不得不寻找其他选择。

I ended up solving the problem simply by switching to Nginx and using the example code in the repository. 我最终只是通过切换到Nginx并使用存储库中的示例代码来解决了问题。 If anyone is in this exact situation I recommend not going through the toil I did and just switch if my situation is similar to yours. 如果有人处在这种确切的情况下,我建议不要经历我辛苦的工作,如果我的情况与您的情况相似,请立即进行切换。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM