From what I understand Node.js doesnt need NginX to work as a http server (or a websockets server or any server for that matter), but I keep reading about how to use NginX instead of Node.js internal server and cant find of a good reason to go that way
-
I think it is more suitable for ServerFault. – mbq Jul 06 '10 at 13:11
-
NGINX is way better at server static content than Node, It's explained in this blogpost http://blog.donaldderek.com/2013/08/cf-i-configure-your-staging-machine-with-node-js-and-nginx/ – Donald Derek Sep 02 '13 at 11:45
3 Answers
Here http://developer.yahoo.com/yui/theater/video.php?v=dahl-node Node.js author says that Node.js is still in development and so there may be security issues that NginX simply hides.
On the other hand, in case of a heavy traffic NginX will be able to split the job between many Node.js running servers.

- 18,510
- 6
- 49
- 72
In addition to the previous answers, there’s another practical reason to use nginx in front of Node.js, and that’s simply because you might want to run more than one Node app on your server.
If a Node app is listening on port 80, you are limited to that one app. If nginx is listening on port 80 it can proxy the requests to multiple Node apps running on other ports.
It’s also convenient to delegate TLS/SSL/HTTPS to Nginx. Doing TLS directly in Node is possible, but it’s extra work and error-prone. With Nginx (or another proxy) in front of your app, you don’t have to worry about it and there are tools to help you securely configure it.

- 18,752
- 8
- 48
- 54
But be prepared: nginx don't support http 1.1 while talking to backend so features like keep-alive or websockets won't work if you put node behind the nginx.
UPD: see nginx 1.2.0 - socket.io - HTTP/1.1 - Proxy websocket connections for more up-to-date info.

- 1
- 1

- 21,908
- 8
- 73
- 65
-
-
2What he means is that NginX can talk Http 1.1 to clients connecting to him, but not to proxy'ed servers, for example if you have a NodeJS application that implements Socket.io and you connect to that application via NginX, it simply will not work for websockets – Purefan Sep 26 '11 at 06:52
-
2Nginx does [support HTTP 1.1 since version 1.2.0](http://wiki.nginx.org/Main). Can you please update your answer? – Dan Dascalescu Feb 11 '13 at 09:09
-
1I didn't know this, thanks for the pointer. I've updated the answer with a link to a dedicated question. – Mikhail Korobov Feb 12 '13 at 05:52