簡體   English   中英

如何在運行apache的端口443上運行socket.io?

[英]How to run socket.io on port 443 where apache is running?

我需要在端口443上運行socket.io(其中apache使用Let的加密運行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 HTTPS站點上運行socket.io工作正常,但我得到了http 404錯誤。 我想問題是在rewriteCond上。

websocket.js:112 WebSocket連接到'wss://mysite.com/socket.io/?id = 11518237&username = john failed:WebSocket握手期間出錯:意外響應代碼:404

為不同的用途使用不同的IP地址。 您有<VirtualHost *:443> ,它嘗試使用單個虛擬主機的所有IP地址。 我想你想要一個用於Let的加密的<VirtualHost pub.lic.ip.addr:443>和一個用於socket.io代理的<VirtualHost localhost:443>

嘗試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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM