Is it possible to setup a WebSockets server behind an nginx server which handles connections on a UNIX domain socket?
I currently have several WebSocket server instances on the same machine and have the problem of port sharing. All instances must be allocated a unique port. I want to avoid that and instead communicate between nginx and the WebSockets backend using UNIX domain sockets.
The WebSockets library I'm using is ws (https://github.com/einaros/ws)
I currently create my server like this:
var WebSocketServer = require('ws').Server;
var wss = new WebSocketServer({host: "127.0.0.1", port: 8080});
Server side:
var http = require('http');
var WebSocketServer = require('ws').Server;
var server = http.createServer()
var wss = new WebSocketServer({ server : server});
server.listen('/tmp/server.sock')
Client side:
var ws = require('ws');
var client = new ws("ws+unix:///tmp/server.sock")
client.send('hello')
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