I was trying to introduce socket.io to my application developed in Laravel and in AngularJS.
The application works fine in my computer, nevertheless when I try to make i
Socket.io use /socket.io after your domaine name. Then you have to specify the socket.io location :
location ~* \.io {
proxy_pass http://localhost:8080;
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;
}
And don't forget the upstream for your node js app
upstream app_yourdomain {
server 127.0.0.1:3000;
keepalive 8;
}
For anyone else who is might be trying to figure this out like me, I just got this working after 4 hours of trying on a digital ocean server.
Follow the working solution that OP edited into the answer solved half of it, however I had to use a cdn for the links inside my html files.
Here's the cdn's to choose from https://cdnjs.com/libraries/socket.io.
Pick one and replace the url in <script src="http://localhost:3000/socket.io/socket.io.js"></script>
with the cdn on the pages where you need it.
For my client side javascript (or angular in this case), just use the public domain name that you want to connect to the app with.
Also, make sure you add the the stuff you don't have in your nginx setup that OP wrote in the working answer. No need for the php section unless you're using php. I'm not so I omitted it. Make sure that you replace 'app_example.com' with the same address or domain that you used in your client side javascript.
This probably isn't the right place to post this but I can't comment yet and I don't want other people going through 4 hours of trial and error.