Skip to content

Instantly share code, notes, and snippets.

@PierreLebedel
Last active January 28, 2024 15:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PierreLebedel/eb8220746d6722d0389bf03306fe999b to your computer and use it in GitHub Desktop.
Save PierreLebedel/eb8220746d6722d0389bf03306fe999b to your computer and use it in GitHub Desktop.
Configuration files for beyondcode/laravel-websockets:1.14.1 on Laravel 10 with Supervision and SSL on Apache 2.4
PUSHER_APP_ID=examplesite-appid
PUSHER_APP_KEY=examplesite-appkey
PUSHER_APP_SECRET=examplesite-appsecret
PUSHER_APP_CLUSTER=mt1
PUSHER_HOST=www.examplesite.com
PUSHER_PORT=6001
PUSHER_SCHEME=http
LARAVEL_WEBSOCKETS_PORT=443
LARAVEL_WEBSOCKETS_VERIFY_PEER=false
#LARAVEL_WEBSOCKETS_SSL_LOCAL_CERT=/etc/letsencrypt/live/examplesite.com/fullchain.pem
#LARAVEL_WEBSOCKETS_SSL_LOCAL_PK=/etc/letsencrypt/live/examplesite.com/privkey.pem
#LARAVEL_WEBSOCKETS_SSL_PASSPHRASE=
MIX_APP_NAME="${APP_NAME}"
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_HOST="${PUSHER_HOST}"
MIX_PUSHER_PORT="${PUSHER_PORT}"
MIX_PUSHER_SCHEME="${PUSHER_SCHEME}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
<VirtualHost *:80>
ServerName examplesite.com
Redirect / https://www.examplesite.com
</VirtualHost>
<VirtualHost _default_:443>
ServerName examplesite.com
ServerAlias examplesite.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www/examplesite/public/
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
ProxyPass "/app/" "ws://127.0.0.1:6001/app/"
ProxyPassReverse "/app/" "ws://127.0.0.1:6001/app/"
SSLEngine on
SSLCertificateFile /etc/letsencrypt/live/examplesite.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/examplesite.com/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
'connections' => [
'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'),
'useTLS' => false,
'encrypted' => false,
'host' => env('PUSHER_HOST', '127.0.0.1'),
'port' => env('PUSHER_PORT', 6001),
'scheme' => env('PUSHER_SCHEME', 'http'),
'curl_options' => [
CURLOPT_SSL_VERIFYHOST => 0,
CURLOPT_SSL_VERIFYPEER => 0,
]
],
'client_options' => [
'verify' => false,
],
],
...
'dashboard' => [
'port' => env('LARAVEL_WEBSOCKETS_PORT', 443),
],
'apps' => [
[
'id' => env('PUSHER_APP_ID'),
'name' => env('APP_NAME'),
'key' => env('PUSHER_APP_KEY'),
'secret' => env('PUSHER_APP_SECRET'),
'path' => env('PUSHER_APP_PATH'),
'capacity' => null,
'enable_client_messages' => true,
'enable_statistics' => true,
],
],
...
'ssl' => [
'local_cert' => env('LARAVEL_WEBSOCKETS_SSL_LOCAL_CERT', null),
'local_pk' => env('LARAVEL_WEBSOCKETS_SSL_LOCAL_PK', null),
'passphrase' => env('LARAVEL_WEBSOCKETS_SSL_PASSPHRASE', null),
'verify_peer' => env('LARAVEL_WEBSOCKETS_VERIFY_PEER', false),
'verify_peer_name' => env('LARAVEL_WEBSOCKETS_VERIFY_PEER', false),
'allow_self_signed' => true,
],
...
import Echo from 'laravel-echo';
window.Pusher = require('pusher-js');
window.Echo = new Echo({
broadcaster : 'pusher',
cluster : process.env.MIX_PUSHER_APP_CLUSTER,
key : process.env.MIX_PUSHER_APP_KEY,
wsHost : process.env.MIX_PUSHER_HOST,
wsPort : process.env.MIX_PUSHER_PORT,
forceTLS : false,
encrypted : false,
enableLogging : true,
disableStats : true,
enabledTransports: ['ws', 'wss'],
});
[program:websockets]
command=/usr/bin/php /var/www/examplesite/artisan websockets:serve --port 6001
numprocs=1
autostart=true
autorestart=true
user=ubuntu
stdout_logfile=/var/www/examplesite/storage/logs/websockets.log
stdout_logfile_maxbytes=10MB
stdout_logfile_backups=0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment