3

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?

littlejim84
  • 267
  • 1
  • 3
  • 9
  • Nginx 1.1 (currently marked as the development version, but it seems pretty stable) does support http/1.1 to back-ends, so that might work if you can use it – Shish Feb 07 '12 at 17:57

1 Answers1

2

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.

nic ferrier
  • 273
  • 2
  • 10
  • Hello Nic. Maybe that's a point really. I'm using web sockets heavily (which can be done with Nginx but needs compiling again with the right module) and most of my static files are actually coming from Amazon S3. I'm trying to toss up Nginx over node-http-proxy. Having Node.js right up there on port 80 shouldn't be a problem? Many people do this I believe? – littlejim84 Feb 07 '12 at 14:48
  • I think people do it, personally I'd be wary of it because of security and stability concerns. But if your application isn't that sensitive it's worth a try. If it all breaks or gets broken into too often you can always add nginx (or whatever) later. No big deal. – nic ferrier Feb 08 '12 at 09:21
  • Just to note, nginx 1.3 now has websocket proxy support. You absolutely should use nginx now to front node.js. – nic ferrier Feb 25 '13 at 18:14