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

2019-03-30 01:17发布

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?

2条回答
Luminary・发光体
2楼-- · 2019-03-30 01:58

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.

查看更多
混吃等死
3楼-- · 2019-03-30 02:02

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.

查看更多
登录 后发表回答