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

后端 未结 5 1934
猫巷女王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条回答
  •  Happy的楠姐
    2020-12-05 12:43

    After reading several answers, posting on the Meteor forum, and a lot of trials here is the whole enchilada that worked for me. The other answers were somewhat incomplete, or at least didn't work for me.

    I had to do:

    sudo a2enmod proxy_wstunnel 
    

    Also had to add a ProxyPass and ProxyPassReverse and changed ^Upgrade$ to Upgrade$ from another SO answer.

    
        ServerName  some-domain.com
    
        RewriteEngine on
        RewriteCond %{HTTP:UPGRADE} ^WebSocket$ [NC]
        RewriteCond %{HTTP:CONNECTION} Upgrade$ [NC]
        RewriteRule .* ws://localhost:3000%{REQUEST_URI} [P]
    
        ProxyPass / http://localhost:3000/
        ProxyPassReverse / http://localhost:3000/
    
    
    

    then restart Apache.

    I checked on the console and there is no error now and no xhr requests. So I assume it's working correctly

提交回复
热议问题