2016-03-01 21 views
3

我有一个正在为Chrome和Internet Explorer下面的Apache2配置:火狐保持活动,通过Apache反向代理升级搞坏的WebSocket

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

我是否需要更改我的Rewriterule?

回答

0

是的,您需要为您的重写规则添加条件。下面的配置将工作,因为它会检查的Upgradekeep-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]