Working on Laravel 10, with Laravel WebSockets, pusher, and laravel-echo. Using Ngnix I added a self-signed SSL certificate, the application is working in https but the web socket secure is not connecting to the local machine (windows).
listen 80 ;
server_name real.web.com;
listen 443 ssl;
ssl on;
ssl_certificate C:\certificate\websock\real.web.pem;
ssl_certificate_key C:\certificate\websock\private-key.pem;
root E:\\real-web\\public;
location /
{
index index.html index.htm index.php;
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$
{
try_files $uri /index.php = 404;
fastcgi_pass 127.0.0.1:8001;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location /ws
{
proxy_pass http://127.0.0.1:6001;
proxy_set_header Host $host;
proxy_read_timeout 60;
proxy_connect_timeout 60;
proxy_redirect off;
# Allow the use of websockets
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
.env
PUSHER_APP_ID=Zigma.v.0.01
PUSHER_APP_KEY=Zigma@123
PUSHER_APP_SECRET=Zigma@!@#
PUSHER_HOST=127.0.0.1
PUSHER_PORT=6001
PUSHER_SCHEME=http
PUSHER_APP_CLUSTER=mt1
bootstrap.js
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: import.meta.env.VITE_PUSHER_PORT ?? 80,
wssPort: 443,
forceTLS: (import.meta.env.VITE_PUSHER_SCHEME ?? 'https') === 'https',
enabledTransports: ['ws', 'wss'],
});