Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question
    
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 7 '12 at 17:57

1 Answer 1

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.

share|improve this answer
    
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 7 '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 8 '12 at 9: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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.