Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

LaraBABA's avatar

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

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://mywebsite.com:6001/" [P,L]

ProxyPass /app ws://mywebsite.com:6001
ProxyPassReverse /app wss://mywebsite.com:6001

Reloaded httpd and tried to connect via the Laravel websocket panel. I have also followed the setup here: https://docs.beyondco.de/laravel-websockets/1.0/basic-usage/ssl.html#configuration

As:

    '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:

LARAVEL_WEBSOCKETS_SSL_LOCAL_CERT=/home/myaccount/public_html/ssl/ke_com_a25e6_65c3b_1577536339_5996f634be6fba7d72a3bcf7b.crt
LARAVEL_WEBSOCKETS_SSL_LOCAL_PK=/home/myaccount/public_html/ssl/a25e6_65c3b_cc885c0c620bd3119e79f1fd.key

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

pusher.min.js:8 WebSocket connection to 'wss://mywebsite.com:6001/app/mnbmndbf090980df9g8dfgs0d980098fskjh?protocol=7&client=js&version=4.3.1&flash=false' 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.

0 likes
7 replies
luissilva2013's avatar

Please, let us know if you find a proper solution to this problem. It is causing headaches to PHP developers. I am one of those. Looking still for a solution to use laravel WebSocket on my site. WS it works, but on WSS(https) it won't. Thanks in advace!

LaraBABA's avatar

Nothing till now, I gave up the idea of hosting it myself and went with pusher.....:-(

gaidyjg's avatar

You have not yet found an answer? I have the same trouble

User1980's avatar

Did you find a solution by the way please?

Sinnbeck's avatar

@User1980 If using forge or ploi, I suggest using soketi. It is really easy to install, and is pusher compatible. Both have guides on how to set it up

Please or to participate in this conversation.