BULKA
BULKA

Reputation: 1

Laravel 11 Reverb config for production SSL Nginx

Problem with running Laravel 11 Reverb on a production nginx server on a domain with https. I'll tell you right away that everything works on local! I tried and found many options on the Internet, I don't know where to look anymore, I hope for the power of the Internet!:)

About server: AlmaLinux8, nginx, php8.2, Laravel 11

Settings/configs

.ENV

REVERB_APP_ID=412
REVERB_APP_KEY=rl6j5kzxhvpf
REVERB_APP_SECRET=zcvttt0iy
REVERB_HOST=****.com
REVERB_PORT=443
REVERB_SCHEME=https
REVERB_SERVER_HOST=127.0.0.1
LOCAL_CERT="/var/webuzo/users/ssl/****.com-combined.pem"

reverb.php

   '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('LOCAL_CERT'),
                ],
            ],
            'max_request_size' => env('REVERB_MAX_REQUEST_SIZE', 10_000),
            'scaling' => [
                'enabled' => env('REVERB_SCALING_ENABLED', false),
                'channel' => env('REVERB_SCALING_CHANNEL', 'reverb'),
                'server' => [
                    'url' => env('REDIS_URL'),
                    'host' => env('REDIS_HOST', '127.0.0.1'),
                    'port' => env('REDIS_PORT', '6379'),
                    'username' => env('REDIS_USERNAME'),
                    'password' => env('REDIS_PASSWORD'),
                    'database' => env('REDIS_DB', '0'),
                ],
            ],
            'pulse_ingest_interval' => env('REVERB_PULSE_INGEST_INTERVAL', 15),
            'telescope_ingest_interval' => env('REVERB_TELESCOPE_INGEST_INTERVAL', 15),
        ],

    ],

Nginx conf

server {
    listen    66.2*.***.147:443 ssl;
    server_name    ****.com www.****.com mail.****.com;
    # The Document Root
    root      /home/****/public_html/public; 
    ssl_certificate             /var/webuzo/users/****/ssl/****.com-combined.pem;
    ssl_certificate_key          /var/webuzo/users/****/ssl/****.com.key;
    ssl_dhparam                 /etc/ssl/private/dhparam.pem;
    
    set $fpmsocket /usr/local/apps/php82/var/fpm-****.sock;

    location ~ (\.php|phtml|shtml|/)$ {
       try_files  $uri $uri/index.php $uri/index.php8 $uri/index.php7 $uri/index.php5 $uri/index.perl $uri/index.pl $uri/index.plx $uri/index.ppl $uri/index.cgi $uri/index.jsp $uri/index.jp $uri/index.phtml $uri/index.shtml $uri/index.xhtml $uri/index.html $uri/index.htm $uri/index.js;
       fastcgi_pass unix:$fpmsocket;
       fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
       fastcgi_param  SCRIPT_NAME       $fastcgi_script_name;
       include          fastcgi_params;
    }
    error_log  /usr/local/apps/nginx/var/log/****.com.err;
    access_log /usr/local/apps/nginx/var/log/****.com.log main;
    
    #webmail access from /webmail
    location ^~ /webmail {
       proxy_set_header Host $host;
       proxy_set_header Connection keep-alive;
       proxy_set_header X-Original-URI $request_uri;
       rewrite ^/webmail$ /webmail/ permanent;
       proxy_pass https://127.0.0.1:2003/mail/;
    }

    # Laravel Reverb
# The Websocket Client/Laravel Echo would connect and listen to this
location ~ /app/(?<reverbkey>.*) { # variable reverbkey
  proxy_pass http://127.0.0.1:8080/app/$reverbkey;
  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";
}
# The Laravel Backend would broadcast to this
location ~ ^/apps/(?<reverbid>[^/]+)/events$ { # variable reverbid
  proxy_pass http://127.0.0.1:8080/apps/$reverbid/events;
  proxy_set_header Host $host;
  proxy_set_header X-Real-IP $remote_addr;
  proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  proxy_set_header X-Forwarded-Proto $scheme;
}
    
    set $noindex @maintenance;
    include       /usr/local/apps/nginx/etc/conf.d/common;
    include /var/webuzo-data/nginx/custom/domains/****.com.conf;

    
    # Stop proxy /.well-known folder
    location /.well-known {
       
    }
}

Running commands

php artisan config:cache

php artisan config:clear

npm run build

php artisan reverb:start --debug

php artisan queue:work

Errors

On the page in the browser terminal in the console: WebSocket connection to 'wss://****.com/app/rl6j5kzxhvpflsapa1h3?protocol=7&client=js&version=8.4.0-rc2&flash=false' failed

On log file /usr/local/apps/nginx/var/log/** ***.com.err;

[error] 61213#0: *204 upstream prematurely closed connection while reading response header from upstream, client: 193.238.**.213, server: **.com, request: "GET /app/rl6j5kzxhvpflsapa1h3?protocol=7&client=js&version=8.4.0-rc2&flash=false HTTP/1.1", upstream: "http://127.0.0.1:8080/apprl6j5kzxhvpflsapa1h3?protocol=7&client=js&version=8.4.0-rc2&flash=false", host: " * * *.com"

From the very beginning I tested all this on Apache, nothing worked, I installed Nginx and the same thing... I tried to set: REVERB_SERVER_HOST=0.0.0.0 REVERB_SERVER_PORT=6001 (then nginx conf, change: proxy_pass http://0.0.0.0:6001/app) The path to the LOCAL_CERT certificate is correct I don't know what I'm missing :( I'm waiting for your suggestions, I hope we can solve this problem

Upvotes: 0

Views: 167

Answers (0)

Related Questions