-
Notifications
You must be signed in to change notification settings - Fork 658
websocket on nginx not response #548
Description
hi
i am using the awesome package.
all things in localhost is okey and it works perfectly.
but i deploy my laravel app on nginx server and i cant works with socket.
i studied almost all of issue in this package but i have yet problem.
1: i use "Pusher Replacement":
https://beyondco.de/docs/laravel-websockets/basic-usage/pusher
2: i dont use ssl(https) in laravel-websocket config and only us http.
https://beyondco.de/docs/laravel-websockets/basic-usage/ssl
3: my laravel config:
LARAVEL_WEBSOCKETS_PORT=6001 LARAVEL_WEBSOCKETS_SSL=false LARAVEL_WEBSOCKETS_HOST=127.0.0.1 LARAVEL_WEBSOCKETS_SSL_LOCAL_CERT=null LARAVEL_WEBSOCKETS_SSL_LOCAL_PK=null
4: my nginx config:
`
server {
listen 80;
root /var/www/html/example.test/caropex-laravel/public;
index index.php index.html index.htm index.nginx-debian.html;
server_name example.test www.example.test;
#TODO: This header will prevent search engines from indexing your https pages
add_header X-Robots-Tag "noindex, nofollow, nosnippet, noarchive";
location ~ ^/(admin|api|images|sitemaps)/? { #laravel
proxy_read_timeout 600s;
try_files $uri $uri/ /index.php?$query_string;
}
location /app { #websocket
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;
}
location / { #react
if (!-f $request_filename){
proxy_pass http://127.0.0.1:3000;
break;
}
}
location ~ \.php$ {
proxy_read_timeout 600s;
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
}
location ~ /\.ht {
deny all;
}
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/example.test/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/example.test/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
}
`
i will getting this error in browser console:
Firefox can’t establish a connection to the server at wss://example.text:6001/app/caropex_9501051423?protocol=7&client=js&version=4.3.1&flash=false.