After reading several articles, I'm still unable to get my socket.io communication working via a nginx proxy.
Below is my nginx
configuration:
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
location ~* \.io {
proxy_pass http://localhost:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
}
Here's how my node.js
express server is wired up:
const express = require('express');
const app = express();
const http = require('http').Server(app);
const io = require('socket.io')(http);
Everything seems to work fine on my local dev machine ie. I'm seeing my onConnection log message and all communication works well too.
On production howsoever, my browser gets all valid responses but I'm not seeing any onConnection logs and communication over the socket isn't working.
Chrome network tab requests (click to open image in full size)