Apache2 WebSockets reverse proxy on same URL

前端 未结 2 1423
孤城傲影
孤城傲影 2020-12-30 08:12

How to configure Apache2 to proxy WebSocket connection (BrowserSync for example), if it\'s made on the same URL, with only difference being header \"Upgrade: websocket\" and

2条回答
  •  渐次进展
    2020-12-30 08:16

    Thanks a lot to metalim! I publish the full configuration here for reference:

    
        ServerName example.org
        ServerAlias *.example.org
        ServerAdmin sysadmin@example.org
        ProxyRequests Off
        ProxyPreserveHost On
    
        RewriteEngine On
        RewriteCond %{HTTP:Connection} Upgrade [NC]
        RewriteCond %{HTTP:Upgrade} websocket [NC]
        RewriteRule /(.*) ws://192.168.1.1/$1  [P,L]
    
        ProxyPass / http://192.168.1.1/ retry=1
        ProxyPassReverse / http://192.168.1.1/
    
        ErrorLog /var/log/apache2/example.org.error.log
        CustomLog /var/log/apache2/example.org.access.log combined
    
    

提交回复
热议问题