laravel / reverb

Laravel Reverb provides a real-time WebSocket communication backend for Laravel applications.

Home Page:https://reverb.laravel.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

reverb wont work with ssl on ubuntu

ahmedalkhairy opened this issue · comments

Reverb Version

1.0.0-(beta9)

Laravel Version

11.5

PHP Version

8.2.16

Description

i have a problem since announcing laravel reverb
i run laravel app on ubuntu 22 server ,
apache2
php 8.2

reverb works good with no ssl , but when i activate ssl , it refuse to handshake

reverb config:

'servers' => [

    'reverb' => [
        'host' => env('REVERB_SERVER_HOST', '0.0.0.0'),
        'port' => env('REVERB_SERVER_PORT', 8080),
        'hostname' => env('REVERB_HOST'),
        'options' => [
            'tls' => [
    'local_cert' => env('REVERB_SSL_LOCAL_CERT'),
    'verify_peer' => false,
],
            ],
        'scaling' => [
            'enabled' => env('REVERB_SCALING_ENABLED', false),
            'channel' => env('REVERB_SCALING_CHANNEL', 'reverb'),
        ],
        'pulse_ingest_interval' => env('REVERB_PULSE_INGEST_INTERVAL', 15),
    ],

],

.env

REVERB_SERVER_HOST=0.0.0.0
REVERB_SERVER_PORT=8080
REVERB_HOST="cp.*****.com"
REVERB_PORT=443

getting error in apache logs
AH00961: https: failed to enable ssl support for 127.0.0.1:8080 (localhost)

i have tried to remove ssl options , and redirect from .htaccess , always the samp

Steps To Reproduce

install laravel 11 app
setup reverb config as docs
activate ssl

i have same problem

What does your Apache configuration look like?

<VirtualHost *:80>
ServerName reverb.xxxxxx.com

ProxyPass / http://0.0.0.0:8080/
ProxyPassReverse / http://0.0.0.0:8080/

ProxyPreserveHost On

RewriteEngine on
RewriteCond %{SERVER_NAME} =reverb.xxxxx.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]

i have also tried with another server running nginx

server {
server_name reverb.sellenvo.com;
root /var/www/reverb/public;

add_header X-Frame-Options "SAMEORIGIN";
add_header X-XSS-Protection "1; mode=block";
add_header X-Content-Type-Options "nosniff";

index index.html index.htm index.php;

charset utf-8;

    location / {

try_files $uri $uri/ /index.php?$query_string;

}

location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt  { access_log off; log_not_found off; }

error_page 404 /index.php;

location ~ \.php$ {
    fastcgi_pass unix:/var/run/php/php8.2-fpm.sock;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
    include fastcgi_params;
}

location /app/ {

proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
proxy_pass http://0.0.0.0:8080;

proxy_read_timeout 300s;
proxy_connect_timeout 75s;

access_log /var/log/nginx/app_access.log;

proxy_redirect off;
}

location ~ /\.(?!well-known).* {
    deny all;
}

listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/reverb.xxxx.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/reverb.xxxxxx.com/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

}
server {
if ($host = reverb.sellenvo.com) {
return 301 https://$host$request_uri;
} # managed by Certbot

listen 80;
server_name reverb.xxxxxx.com;
return 404; # managed by Certbot

}

It's been a while since I have worked with Apache, but is part of the issue that you only have a VirtualHost running on port 80?

With Nginx, you can't use location /app/ as not every route into the Reverb server is prefixed with app.

I have same problem.
This code is work in localhost but when i push this code to the production server it will not work.. reverb connection is success but when i want to broadcast the event it throw the error

This is the connection status

image

my .env

BROADCAST_CONNECTION=reverb
VITE_APP_NAME="${APP_NAME}"

REVERB_SERVER_HOST=127.0.0.1
REVERB_SERVER_PORT=8080

REVERB_APP_ID=920552
REVERB_APP_KEY=mop6z2fyoey59fm7l3ro
REVERB_APP_SECRET=eehaek3gn748kcyfcqxq
REVERB_HOST="reverb.xxxx.com"
REVERB_PORT=443
REVERB_SCHEME=https

VITE_REVERB_APP_KEY="${REVERB_APP_KEY}"
VITE_REVERB_HOST="${REVERB_HOST}"
VITE_REVERB_PORT="${REVERB_PORT}"
VITE_REVERB_SCHEME="${REVERB_SCHEME}"

my broadcast config is

connections' => [

        'reverb' => [
            'driver' => 'reverb',
            'key' => env('REVERB_APP_KEY'),
            'secret' => env('REVERB_APP_SECRET'),
            'app_id' => env('REVERB_APP_ID'),
            'options' => [
                'host' => env('REVERB_HOST'),
                'port' => env('REVERB_PORT', 443),
                'scheme' => env('REVERB_SCHEME', 'https'),
                'useTLS' => env('REVERB_SCHEME', 'https') === 'https',
            ],
            'client_options' => [
                // Guzzle client options: https://docs.guzzlephp.org/en/stable/request-options.html
            ],
        ],

        'pusher' => [
            'driver' => 'pusher',
            'key' => env('PUSHER_APP_KEY'),
            'secret' => env('PUSHER_APP_SECRET'),
            'app_id' => env('PUSHER_APP_ID'),
            'options' => [
                'cluster' => env('PUSHER_APP_CLUSTER'),
                'host' => env('PUSHER_HOST') ?: 'api-'.env('PUSHER_APP_CLUSTER', 'mt1').'.pusher.com',
                'port' => env('PUSHER_PORT', 443),
                'scheme' => env('PUSHER_SCHEME', 'https'),
                'encrypted' => true,
                'useTLS' => env('PUSHER_SCHEME', 'https') === 'https',
            ],
            'client_options' => [
                // Guzzle client options: https://docs.guzzlephp.org/en/stable/request-options.html
            ],
        ],
]

my event file is

namespace App\Events;


use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Contracts\Broadcasting\ShouldBroadcastNow;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;

class MessageTypingEvent implements ShouldBroadcastNow
{
    use Dispatchable, InteractsWithSockets, SerializesModels;

    public $from;

    public $to;

    public $type;

    /**
     * Create a new event instance.
     */
    public function __construct($from,$to,$type)
    {
        $this->from = $from;
        $this->to = $to;
        $this->type = $type;

    }

    /**
     * Get the channels the event should broadcast on.
     *
     * @return array<int, \Illuminate\Broadcasting\Channel>
     */
    public function broadcastOn(): array
    {
        return [
            new PrivateChannel('message_typing'.$this->to),
        ];
    }
}

when i call this function

public function removeReading($id)
    {
        
        MessageTypingEvent::dispatch(auth()->user()->id, $id,'stop');
    }

my route is

Broadcast::channel('message_typing{id}', function($user,$id){
    return (int) $user->id === (int) $id;
});

it through the error is

. {"userId":4,"exception":"[object] (Illuminate\Broadcasting\BroadcastException(code: 0): Pusher error:
at /var/www/xxxx/vendor/laravel/framework/src/Illuminate/Broadcasting/Broadcasters/PusherBroadcaster.php:164)

If you start the server with debug mode enabled (php artisan reverb:start --debug), you might be able to see the cause.

I don't think this is related to the original issue though, so please open a new one if you are unable to track it down. Closing this issue for now due to lack of activity.