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.
Asked
Active
Viewed 5,186 times
10
-
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 Answers
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
-
Neat trick! Now how do you get Firefox to connect to that socket and send an HTTP request? Just kidding. – Celada Feb 01 '13 at 22:07
-