Why install server (Nginx, Apache…) with Node.js?

2019-03-30 01:32发布

问题:

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?

回答1:

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.



回答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.