7 months ago

Unable to setup Websockets on WSS on Apache 2.4 (Centos)

Posted 7 months ago by Boubou

Hello all,

I have been for 3 days on this and it is time for me to call it off, I cannot work it out and my server support refuses to help me further as they are not specialized in websockets. Using WS it works, but on WSS(https) it won't.

I am running Apache/2.4.41 (cPanel)

I have installed 3 php modules from the cpanel: -mod_proxy -mod_proxy_wstunnel -mod_proxy_http

My https.conf file has an external setting file in which I can drop some code(to stop me from editing the main.conf file).

I added this:

  SSLProxyEngine on
  SSLProxyVerify none 
  SSLProxyCheckPeerCN off
  SSLProxyCheckPeerName off
  SSLProxyCheckPeerExpire off

  RewriteEngine on
  ProxyRequests off
  ProxyPreserveHost on
  RewriteCond ${HTTP:Upgrade} websocket [NC]
  RewriteCond ${HTTP:Connection} upgrade [NC]
  RewriteRule .* "ws://" [P,L]

ProxyPass /app ws://
ProxyPassReverse /app wss://

Reloaded httpd and tried to connect via the Laravel websocket panel. I have also followed the setup here:


    'ssl' => [
         * Path to local certificate file on filesystem. It must be a PEM encoded file which
         * contains your certificate and private key. It can optionally contain the
         * certificate chain of issuers. The private key also may be contained
         * in a separate file specified by local_pk.
        'local_cert' => env('LARAVEL_WEBSOCKETS_SSL_LOCAL_CERT', null),

         * Path to local private key file on filesystem in case of separate files for
         * certificate (local_cert) and private key.
        'local_pk' => env('LARAVEL_WEBSOCKETS_SSL_LOCAL_PK', null),

         * Passphrase for your local_cert file.
        'passphrase' => env('LARAVEL_WEBSOCKETS_SSL_PASSPHRASE', null),

        'verify_peer' => false,

.env file in Laravel:


When clicking on the connect button of the laravel websocket dashboard, I get this error:

pusher.min.js:8 WebSocket connection to 'wss://' failed: WebSocket opening handshake was canceled

I have nothing else in my logs.

Could someone please tell me if my httpd setup is correct?

Thank you.

Please sign in or create an account to participate in this conversation.