Firefox Keep-Alive,通过 apache 反向代理升级破坏 websocket



我有以下适用于chrome和Internet Explorer的apache2配置:

Listen 80
IncludeOptional conf.d/*.conf
LoadModule proxy_wstunnel_module modules/mod_proxy_wstunnel.so
<VirtualHost *:80>
        #ProxyRequests On
        ProxyPass / http://IP:8585/
        ProxyPassReverse / http://IP:8585/
        ProxyPass /call  ws://IP:8585/call
        ProxyPassReverse /call  ws://IP:8585/call
        ProxyPass /call/  ws://IP:8585/call/
        ProxyPassReverse /call/  ws://IP:8585/call/
        RewriteEngine on
        RewriteCond %{HTTP:UPGRADE} ^WebSocket$ [NC]
        RewriteCond %{HTTP:CONNECTION} ^Upgrade$ [NC]
        RewriteRule .* ws://localhost:8585%{REQUEST_URI} [P]
</VirtualHost>

问题是它无法通过火狐工作。

我看到的唯一区别是 火狐发送Connection: keep-alive, Upgrade 而不是简单地Upgrade .

我需要更改我的重写规则吗?

是的,您需要在重写规则中添加条件。 以下配置将在检查 Upgrade keep-alive, Upgrade 的连接值时工作:

RewriteEngine on
RewriteCond %{HTTP:UPGRADE} ^WebSocket$ [NC]
RewriteCond %{HTTP:CONNECTION} ^Upgrade$ [NC,OR]
RewriteCond %{HTTP:CONNECTION} ^keep-alive, Upgrade$ [NC]
RewriteRule .* ws://localhost:8585%{REQUEST_URI} [P]

相关内容

  • 没有找到相关文章

最新更新