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

时间:2016-03-01 09:58:32

标签: apache firefox 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>

问题是它无法通过firefox工作。

我看到的唯一区别是firefox发送Connection: keep-alive, Upgrade而不是Upgrade

我需要更改我的重写吗?

1 个答案:

答案 0 :(得分:1)

是的,您需要为重写规则添加条件。以下配置可用于检查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]