502 Bad Gateway. Proxy socket.io using Nginx #273
Comments
On your My nginx config in a dev environment that proxies correctly looks something like:
|
Hi @skeith69 did this solve your issue, or did you resolve it yourself somehow...? I am having the same problem, and this didn't resolve it for me. |
@J5Dev yes I resolved the issue myself. change the SUB-DOMAIN and DOMAIN to what you have. like for me
and
Here it my nginx web socket server block /etc/nginx/sites-available/socket.test.domain.com server block file
here is my laravel-echo-server.json file
resources/assets/js/bootstrap.js file
then run the laravel-echo-server start in your server or put it in your supervisor for auto start up. |
this help me alot! tnks @skeeith
thing you could close the issue |
@jonathanpmartins @skeeith for allowOrigin, it should either be one single URL, or just I've ran into issues with other applications/services where if providing a incorrect value or multiple values, it would cause it to fail as well. I'm assuming it hasn't caused any issue for you since it sounds like it's working - but just pointing out since it sent me in a weird loop a while back.. |
Hey there, this issue was opened a while ago. I'm going to close this issue, if this issue still exists, please open a new issue or open a Pull Request. |
Just to provide some clarification as the solution provided isn't very clear, an upstream allows you to define one or more servers to proxy requests through proxy_pass. As far as I can see, anyone that wants to host the Laravel Echo Server on the same box as Nginx will come across this issue. The solution is to define an upstream that will proxy all requests to I wrote an article on my blog about the migration to the Laravel Echo Server (from Pusher) if anyone else is going through the same transition or is interested in reading over it. TL;DR: Add an upstream server and proxy the requests through it:
And within the
Your nginx configuration files should be located at If you're using Laravel Forge, you can modify the nginx configuration for the affected site(s) within the Forge front-end directly. |
Read your article and have tried everything and I can't get this to work in any form. I always get a 502 Bad Gateway on my Homestead server. I have it set up exactly as in your blog post. Need some help. |
I resolved this by specifying the host in the upstream block upstream websocket {
server domain.tld:6001;
} Thanks for the great solution. |
I have the same problem, but everything I've tried doesn't help. |
@ahusnullin I replied to your stackoverflow question. |
I don't know what the problem is, but I found a solution. Attention: this only works if you write location /socket.io. |
Windows 10 Home Single Language
NodeJS v8.9.4
using Homestead as server (192.168.10.10)
SCENERIO
2 domains
domain-name.dev (Web App Domain)
socket.domain-name.dev (Socket Sub Domain)
SERVER BLOCK CONFIGURATION
server {
listen 80;
listen 443 ssl;
server_name domain-name.dev;
}
CONSOLE LOG OUTPUT
https://socket.domain-name.com/socket.io/?EIO=3&transport=polling&t=M7Ork96 502 (Bad Gateway)
Laravel-Echo-Server Config
{
"authHost": "https://domain-name.dev",
"authEndpoint": "/broadcasting/auth",
"clients": [
{
"appId": "abe8852957c867cf",
"key": "67c71c1f7b7cbb70fbbeda6f340c2891"
}
],
"database": "redis",
"databaseConfig": {
"redis": {
"port": "6379",
"host": "192.168.10.10",
"password": "960c3dac4fa81b4204779fd16ad7c954f95942876b9c4fb1a255667a9dbe389d"
},
"sqlite": {
"databasePath": "/database/laravel-echo-server.sqlite"
}
},
"devMode": false,
"host": null,
"port": "6001",
"protocol": "https",
"socketio": {},
"sslCertPath": "/etc/nginx/ssl/domain-name.dev.dev.crt",
"sslKeyPath": "/etc/nginx/ssl/domain-name.dev.key",
"sslCertChainPath": "",
"sslPassphrase": "",
"apiOriginAllow": {
"allowCors": true,
"allowOrigin": ".",
"allowMethods": "GET, POST",
"allowHeaders": "Origin, Content-Type, X-Auth-Token, X-Requested-With, Accept, Authorization, X-CSRF-TOKEN, X-Socket-Id"
}
}
The text was updated successfully, but these errors were encountered: