As explained on nginx's website I've used these settings for my nginx to proxy websockets to a NodeJS server:
location /socket.io/ {
proxy_pass http://backend;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
Everything works fine and socket.emit() / socket.on() send messages to each other; until I send a rather big text message (26 kB of html).
What am I doing wrong? Is there a nginx setting that I am not aware of?
The "solution" found is to use haproxy to split the tcp stream between nginx and NodeJS.
It is not optimal because it adds yet-another-program in our stack, but it does the job.
It seems to me that nginx websocket support is still far from being production-ready.
Try adding these with your configuration:
proxy_buffers 8 2m;
proxy_buffer_size 10m;
proxy_busy_buffers_size 10m;
Reason : proxy_buffer default size is 4K or 8K. So it could be dropping those connections after the big message causes buffer overflow. Check the default settings here so that it meets you requirements.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With