Set up security websocket (wss) in vesta + php + centos

  1. Enable mod_proxy and mod_proxy_wstunnel module in apache.
    • vi /etc/httpd/conf.modules.d/00-proxy.conf
    • Remove '#' from the beginning of these two lines. If you can't find these two lines from the file, please add them manually.
      LoadModule proxy_module modules/mod_proxy.so
      LoadModule proxy_wstunnel_module modules/mod_proxy_wstunnel.so
  2. Add configuration for the apache
    • vi /home/{username}/conf/web/xxxx.com.httpd.ssl.conf
    • Assume your websocket service on the port 2000. Add the following inside VirtualHost
      # Websocket proxy
      # wss redirects to working ws protocol
      ProxyPass /wss ws://127.0.0.1:2000 retry=0 keepalive=On
      ProxyPassReverse /wss ws://127.0.0.1:2000 retry=0
  3. Restart apache services
  4. Now, you can access the wws form the link like this "wws://xxxx.com/wss/". Please node that don't skip the last character '/'