• Please be aware: Kaspersky Anti-Virus has been deprecated
    With the upgrade to Plesk Obsidian 18.0.64, "Kaspersky Anti-Virus for Servers" will be automatically removed from the servers it is installed on. We recommend that you migrate to Sophos Anti-Virus for Servers.
  • The Horde webmail has been deprecated. Its complete removal is scheduled for April 2025. For details and recommended actions, see the Feature and Deprecation Plan.
  • We’re working on enhancing the Monitoring feature in Plesk, and we could really use your expertise! If you’re open to sharing your experiences with server and website monitoring or providing feedback, we’d love to have a one-hour online meeting with you.

Question [Laravel] How to serve the laravel-websockets in Plesk

peteeeeeee

New Pleskian
Server operating system version
CentOS Linux 7.9.2009 Obsidian
Plesk version and microupdate number
Version 18.0.56 Update #4
I am using beyondcode/laravel-websockets and pusher/pusher-php-server to serve web socket with Laravel.

Additional nginx directives
NGINX:
location /app/ {
    proxy_pass http://127.0.0.1:6001;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
}

I run /opt/plesk/php/8.1/bin/php artisan websockets:serve in ssh, it works fine, but in real work, shouldn't be executed manually like this.

May I know any best practices to serve the web socket in Plesk?
 
Hi

If you need run it as deamon search by supervisord

It should work fine in plesk, but its not supported by plesk officialy.
 
I am using beyondcode/laravel-websockets and pusher/pusher-php-server to serve web socket with Laravel.

Additional nginx directives
NGINX:
location /app/ {
    proxy_pass http://127.0.0.1:6001;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
}

I run /opt/plesk/php/8.1/bin/php artisan websockets:serve in ssh, it works fine, but in real work, shouldn't be executed manually like this.

May I know any best practices to serve the web socket in Plesk?

Hello,

My Laravel codes are as follows.

/resources/js/bootstrap.js
Code:
import Pusher from 'pusher-js';window.Pusher = Pusher;

window.Echo = new Echo({
broadcaster: 'pusher',
key: import.meta.env.VITE_PUSHER_APP_KEY,
cluster: import.meta.env.VITE_PUSHER_APP_CLUSTER ?? 'mt1',
wsHost: window.location.hostname,
wsPort: 6001,
wssPort: 6001,
forceTLS: true,
enabledTransports: ['ws', 'wss'],
});

/config/broadcasting.php
Code:
'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' => '127.0.0.1',
'port' => 6001,
'scheme' => 'https',
'encrypted' => true,
'useTLS' => env('PUSHER_SCHEME', 'https') === 'https',
'curl_options' => [
CURLOPT_SSL_VERIFYHOST => 0,
CURLOPT_SSL_VERIFYPEER => 0,
]
],
'client_options' => [
// Guzzle client options: https://docs.guzzlephp.org/en/stable/request-options.html
],
],
});

/config/websockets.php
Code:
'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' => '/usr/local/psa/var/modules/letsencrypt/etc/live/domain.com/fullchain.pem',

    /*
     * Path to local private key file on filesystem in case of separate files for
     * certificate (local_cert) and private key.
     */
    'local_pk' => '/usr/local/psa/var/modules/letsencrypt/etc/live/domain.com/privkey.pem',

    /*
     * Passphrase for your local_cert file.
     */
    'passphrase' => env('LARAVEL_WEBSOCKETS_SSL_PASSPHRASE', null),
    'verify_peer' => false,
],
websockets are working xammp server but not working centos 7 plesk

How did you get it to work? Can you help me?

I installed supervisor. and I added queue:work and websockets:serve
they are working.

WebSocket connection to 'wss://domain.com:6001/app/aad288c7993ba703e75b?protocol=7&client=js&version=4.3.1&flash=false' failed:

/etc/nginx/nginx.conf

Code:
#user  nginx;
worker_processes  1;

#error_log  /var/log/nginx/error.log;
#error_log  /var/log/nginx/error.log  notice;
#error_log  /var/log/nginx/error.log  info;

#pid        /var/run/nginx.pid;

include /etc/nginx/modules.conf.d/*.conf;

events {
    worker_connections  1024;
}

http {
    include       mime.types;
    default_type  application/octet-stream;

    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log  /var/log/nginx/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;
    #tcp_nodelay        on;

    #gzip  on;
    #gzip_disable "MSIE [1-6]\.(?!.*SV1)";

    server_tokens off;

    include /etc/nginx/conf.d/*.conf;

    location /app/ {
        proxy_pass http://127.0.0.1:6001;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
    }

}
# override global parameters e.g. worker_rlimit_nofile
include /etc/nginx/*global_params;
 
Back
Top