Linux – Is it worth running Nginx for static files of the Node.js app

linuxnginxnode.jssocket

I'm currently writing a web app in Node.js and will soon be setting up my Linux server to make it live. I'm curious, is it worth running Nginx for my Node app's static files? Is it running Nginx to reverse proxy to any other Node apps that maybe running on my server, or should I just use something like node-http-proxy and not use Nginx at all? My Node app will be using socket.io. Due to Nginx's lack of http 1.1 support, there seems to be a work around here.

Basically, is there any advantage to having Nginx sit in front my Node app(s) on my server or will it just get in the way?

Best Answer

I think it is useful to do this.

nginx has a lot of code to shovel files efficiently from the disc to the network socket in a non-blocking way. It does this much more efficiently than node.

Of course, if you're not doing much static content serving then it might not be useful.

But nginx can also load balance over multiple node servers, so that's another potential advantage. Your app has to be written to be scalable like that though.