10

Is there a possibility to listen a node.js-http server natively on a local unix pipe/socket? (e. g. /var/tmp/http.sock). I want to use it in combination with WebSockets and a reverse proxy.

The Wavelength
  • 2,836
  • 2
  • 25
  • 44
  • possible duplicate of [Can node.js listen on UNIX socket?](http://stackoverflow.com/questions/7045614/can-node-js-listen-on-unix-socket) – josh3736 Feb 01 '13 at 21:57
  • I know that node.js can listen on unix pipes. But my question is if this is also possible for the http module. I don't want to implement it by myself if there's a solution available. – The Wavelength Feb 01 '13 at 21:59

1 Answers1

23

Because http is based on net, you can use the same options that the net module has. In fact, the http docs explicitly say that you can listen on a unix socket.

var server = http.createServer();
server.listen('/var/tmp/http.sock');
josh3736
  • 139,160
  • 33
  • 216
  • 263