gpt4 book ai didi

apache - 如何在运行Apache的端口443上运行socket.io?

转载 作者:行者123 更新时间:2023-12-03 15:00:57 25 4
gpt4 key购买 nike

我需要在端口443上运行socket.io(其中apache用“让我们加密”运行https站点)

这个想法是使用一个Apache代理,它将流量重定向到socket.io端口。
我找到了解决方案:

<VirtualHost *:443>
ServerName mysite.com
ServerAlias www.mysite.com

SSLEngine on
SSLProxyEngine On
ProxyRequests Off

SSLCertificateFile /etc/apache2/ssl/mysite.com.crt
SSLCertificateKeyFile /etc/apache2/ssl/mysite.com.key
SSLCertificateChainFile /etc/apache2/ssl/ca.cer

DocumentRoot /var/www/errorPages

ErrorDocument 503 /503.html
ProxyPass /503.html !

ProxyPass / http://localhost:3999/
ProxyPassReverse / http://localhost:3999/

RewriteEngine on
RewriteCond %{HTTP:UPGRADE} ^WebSocket$ [NC]
RewriteCond %{HTTP:CONNECTION} ^Upgrade$ [NC]
RewriteRule .* ws://localhost:3999%{REQUEST_URI} [P]

</VirtualHost>

我在端口3999上运行socket.io
HTTPS站点运行正常,但是出现了HTTP 404错误。
我猜问题出在rewriteCond上。

websocket.js:112 WebSocket connection to 'wss://mysite.com/socket.io/?id=11518237&username=john failed: Error during WebSocket handshake: Unexpected response code: 404

最佳答案

试试mod_proxy_wstunnel
It provides support for the tunnelling of web socket connections to a backend websockets server. The connection is automatically upgraded to a websocket connection
https://httpd.apache.org/docs/2.4/mod/mod_proxy_wstunnel.html

关于apache - 如何在运行Apache的端口443上运行socket.io?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51668268/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com