6

Possible Duplicate:
Why do we need apache under Node.js express web framework?

I wonder why I should install a server such as Nginx or Apache with Node.js. I used to think that the server can help me to handle cache control or something more. But I found out that the Connect static middleware already does it, right?

Community
  • 1
  • 1
Trantor Liu
  • 8,770
  • 8
  • 44
  • 64
  • 2
    http://stackoverflow.com/questions/9287747/why-do-we-need-apache-under-node-js-express-web-framework Does this answer your question? – Ditmar Wendt Jun 18 '12 at 08:24
  • 2
    You can set the cache-control in Node without any frameworks. If you have static assets, you might wanna use a CDN instead. If you don't need to use a server, then don't. – Jonathan Ong Jun 18 '12 at 08:27

2 Answers2

12

If you don't know why you need Nginx or Apache on top of Node.js, then you don't need it.

Nginx does a few things faster (and in some cases easier to configure) than Node.js: proxying, url rewriting, http caching, redirection, static file serving, and load balancing.

If you experience that your Node.js code for any of these roles are growing complex, or turn out to be performance bottlenecks, it's worth investigating. Until then, no need to bother.

Deestan
  • 16,738
  • 4
  • 32
  • 48
2

Using stable and solid web server software as front end can bring several advantages. For example, you can use Nginx for load balancing. Furthermore, security risks can be reduced by not presenting your application server directly to the internet.

Dr. Jan-Philip Gehrcke
  • 33,287
  • 14
  • 85
  • 130
  • 1
    Hi, Gehrcke. Can you tell more about security risks? Can I just use a routing table to redirect requests to a web server behind it? – Trantor Liu Jun 18 '12 at 08:36