Running express.js app behind nginx
Most tutorials online suggests using reverse proxy with TCP socket. I use UNIX socket. I consider it faster - it circumvents all TCP bloat:
Code above removes old socket (if any), starts express app and orders it to listen on /tmp/app.sock
and finally changes permissions so nginx process running other user can connect to it (I believe it is not required on BSD systems).
Nginx part looks like this:
That’s it.
P.S. node.js part is in CoffeeScript.