简体   繁体   English

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

[英]Firefox Keep-Alive, Upgrade ruining websocket through apache reverse proxy

I have the following apache2 configuration that is working for chrome and internet explorer: 我有以下适用于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>

The problem is it does not work through firefox. 问题是它无法通过Firefox运行。

The only difference I have seen is that firefox sends Connection: keep-alive, Upgrade instead of simply Upgrade . 我看到的唯一区别是firefox发送Connection: keep-alive, Upgrade而不是简单的Upgrade

Do I need to change my Rewriterule ? 我需要更改我的重写吗?

Yes, you will need to add a condition to your rewrite rules. 是的,您需要为重写规则添加条件。 The below configuration will work as it checks for Connection values of Upgrade or keep-alive, Upgrade : 以下配置将在检查Upgrade keep-alive, 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]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM