Proxy Websocket Connection via Apache

  • Enable mod_proxy_wstunnel
    sudo a2enmod mod_proxy_wstunnel
    
  • Configure virtual host
    ProxyRequests Off
    ProxyPass "/ws/" "ws://localhost:9020"
    ProxyPass "/wss" "wss://localhost:9020"
    
  • Connect to server using websocket
    var connection = new WebSocket('ws://localhost/ws');
    

Reference
http://blog.revathskumar.com/2015/09/proxy-websocket-via-apache.html

Written on November 13, 2017