How to set up an apache proxy for Meteor/SockJS and WebSocket?

后端 未结 5 1936
猫巷女王i
猫巷女王i 2020-12-05 12:31

I have an apache proxy for a meteor app and apache and meteor are on two separate machines. I need it that way as apache has to serve a lot of real websites and it wouldn\'t

5条回答
  •  再見小時候
    2020-12-05 13:04

    This answer is based on Fatih's answer. His solution fails for browsers that send a connection request header other than "Upgrade", such as "keep-alive, Upgrade". This was the case for me with Firefox 42.

    To tackle the issue for Firefox also, change the apache RewriteCond as follows:

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

    (^Upgrade$ becomes Upgrade$)

    I wanted to put this as a comment to Fatih's answer, however I lack the necessary reputation.

提交回复
热议问题