Quantcast
Channel: Active questions tagged https - Stack Overflow
Viewing all articles
Browse latest Browse all 1571

Laravel Reverb: solving webSocket SSL connection issues on local

$
0
0

Laravel (11.9)Reverb (1.0)

If you're encountering errors while using Laravel Reverb with HTTPS and a self-signed certificate, here's a solution that might help. After struggling with this issue for a couple of hours, I found a fix that worked. Here’s what you need to do:

1. Update Your .env File

Ensure that REVERB_SCHEME is set to https:

REVERB_SCHEME=httpsSSL_CERTIFICATE=path/to/file.crtSSL_CERTIFICATE_KEY=path/to/file.key

2. Configure Nginx

Here’s an example of an Nginx configuration for Reverb:

# Route traffic to Reverb (broadcasting)location @ws {    proxy_http_version 1.1;    proxy_set_header Host $http_host;    proxy_set_header Scheme $scheme;    proxy_set_header SERVER_PORT $server_port;    proxy_set_header REMOTE_ADDR $remote_addr;    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;    proxy_set_header Upgrade $http_upgrade;    proxy_set_header Connection "Upgrade";    proxy_pass http://0.0.0.0:8080;}

3. Update config/reverb.php

Ensure you point to your local certificate and key, and set verify_peer to false if you are using a self-signed certificate:

'options' => ['tls' => ['local_cert' => env('SSL_CERTIFICATE'),'local_pk' => env('SSL_CERTIFICATE_KEY'),'verify_peer' => env('APP_ENV') !== 'local',    ],],

4. Update config/broadcasting.php

Similarly, configure Guzzle client options to disable verification for local environments:

'client_options' => [    // Guzzle client options: https://docs.guzzlephp.org/en/stable/request-options.html'verify' => env('APP_ENV') !== 'local',],

5. Expose port 8080

If you're using Docker, ensure that port 8080 is publicly exposed.

This setup should help you resolve issues related to using Laravel Reverb with HTTPS and a self-signed certificate :)

RECAP:

Initially, I encountered issues with the Nginx configuration. The default configuration from the Laravel documentation was incorrect because the location / directive was already in use. Instead, I needed to use @ws.

Subsequently, I struggled to access port 8080 because I had forgotten to expose it.

Even after exposing the port, the websocket worked over HTTP but failed over HTTPS, despite setting REVERB_SCHEME to https.

Finally, I noticed errors in the console and app logs, which led me to discover incorrect verify_peer settings.


Viewing all articles
Browse latest Browse all 1571

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>