Apache + Node.js + Socket.io-安全的Websocket代理问题

时间:2019-06-12 17:15:50

标签: node.js apache websocket proxy socket.io

我正在尝试将wss设置为使用Socket.io与Apache(XAMPP)和Node.js一起使用

现在它会产生200响应,因此它失败了,并退回到AJAX轮询。寻找有关如何获得101响应的建议。请让我知道其他哪些信息将对您有所帮助。

LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_ajp_module modules/mod_proxy_ajp.so
LoadModule proxy_connect_module modules/mod_proxy_connect.so
LoadModule proxy_html_module modules/mod_proxy_html.so
LoadModule proxy_http_module modules/mod_proxy_http.so
LoadModule proxy_http2_module modules/mod_proxy_http2.so
LoadModule proxy_wstunnel_module modules/mod_proxy_wstunnel.so
LoadModule rewrite_module modules/mod_rewrite.so
LoadModule ssl_module modules/mod_ssl.so
<VirtualHost *:443>
    DocumentRoot "D:/htdocs/mysite"
    ServerName mysite.domain.com
    ServerAlias www.mysite.domain.com
    ServerAdmin admin@example.com
    ErrorLog "D:\data\apache_logs/error.log"
    TransferLog "D:\data\apache_logs/access.log"
    SSLEngine on

    SSLCertificateFile "D:/SSL/Cert/domain.com.crt"
    SSLCertificateKeyFile "D:/SSL/Private/domain.com.key"
    SSLCertificateChainFile "D:/SSL/Cert/intermediate.crt"
    <FilesMatch "\.(cgi|shtml|phtml|php)$">
        SSLOptions +StdEnvVars
    </FilesMatch>
    <Directory "C:/xampp/apache/cgi-bin">
        SSLOptions +StdEnvVars
    </Directory>

    BrowserMatch "MSIE [2-5]" \
             nokeepalive ssl-unclean-shutdown \
             downgrade-1.0 force-response-1.0

    CustomLog "D:\data\apache_logs/ssl_request.log" \
              "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"
Protocols h2 h2c http/1.1

SSLProxyEngine on
ProxyRequests Off 
ProxyPreserveHost On
SSLProxyVerify none 
SSLProxyCheckPeerCN off
SSLProxyCheckPeerName off
SSLProxyCheckPeerExpire off

RewriteEngine On
RewriteRule ^/new_game$ new_game/ [L,R=301]

# This is for normal requests
ProxyPass /new_game https://localhost:3000
ProxyPassReverse /new_game https://localhost:3000

# This is for websocket requests
ProxyPass /wss ws://localhost:3000/
ProxyPassReverse /wss ws://localhost:3000/


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

</VirtualHost>

0 个答案:

没有答案