在Node.js的前反向代理的优势 [英] Advantages of a reverse proxy in front of Node.JS

查看:304
本文介绍了在Node.js的前反向代理的优势的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是具有nginx的或运行,如Node.js的前反向代理的另一个Web服务器的优势是什么?这是什么规定?

What are the advantages of having nginx or another web-server running as a reverse-proxy in front of the Node.JS? What does it provide?

(这个问题是针对有关网络的应用程序,而不是网页的网页事宜)。

(This question is intended for matters concerning web-apps, not web-pages).

感谢您。

推荐答案

我觉得最大的好处是,你就能够使用相同的端口(80),用于多个应用程序。否则,你需要为你的每个应用程序的NodeJS新的IP地址。取决于你如何设置的东西,你还可以配置不同的文件夹和子域,在不同的端口上运行不同的应用程序的NodeJS。如果你正在构建的东西大或复杂的,这是pretty很大。想象一下,能够在另一个应用程序的一个节点的应用程序,你的网站从另一个,和登录的网站(会员区,仪表板等)运行的API。您的负载均衡器可以决定谁需要去哪里(example.com/api* - > api.js,example.com/dashboard* - > dashboard.js,example.com - > app.js)。这不仅是对结垢是有用的,而且当事情打破,一切都没有休息一次。

I think the greatest benefit is that you're then able to use the same port (80) for multiple applications. Otherwise, you'd need a new IP address for each nodejs application you have. Depending on how you set things up, you can also configure different folders and subdomains to different nodejs apps running on different ports. If you're building something big or complex, this is pretty great. Imagine being able to run your APIs on one node application, your website from another, and the logged-in website (member's area, dashboard, etc.) in another app. Your load balancer can determine who needs to go where (example.com/api* -> api.js, example.com/dashboard* -> dashboard.js, example.com -> app.js). This is not only useful for scaling, but also when things break, not everything breaks at once.

要成熟一点,咩。 +的NodeJS 永远 + 于节点HTTP代理 =惊人。运行所有应用1代理服务器以最小的配置/复杂性(失败的机会较低)。然后有一切乐趣。不要忘了防火墙关闭内部端口,但;)

To the maturity thing, meh. Nodejs + forever + node-http-proxy = Amazing. Run 1 proxy server for all of your apps with a minimal config/complexity (lower chance of failure). Then have fun with everything else. Don't forget to firewall off your internal ports, though ;).

有人记下的负载均衡,这真的是一个好处。然而,负载均衡是不是大多数人会从中受益,因为一个单线程的,无阻塞线程的NodeJS可以处理相当IM pressively大负荷。我真的甚至不认为这是一个区别,如果我是你。负载均衡是很容易的实现,当你需要它,但在其他方面完全无用的,直到你怎么做。

Some people make note of load balancing, which true, is a benefit. However, load balancing isn't something that most people will benefit from, since a single threaded, non-blocking nodejs thread can handle quite impressively large loads. I truly wouldn't even consider this as a difference if I were you. Load balancing is easy enough to implement when you need it, but otherwise utterly useless until you do.

另外请注意,如果你去一个非节点代理解决方案(nginx的,龙卷风等),只是确保不使用一个块。 的Apache模块。 Nginx的没有。你不想扔掉的照出服务器上使用的NodeJS摆在首位的最大好处之一。

Also note, if you do go with a non-node proxy solution (nginx, tornado, etc.), just be sure NOT to use one that blocks. Apache blocks. Nginx doesn't. You don't want to throw away one of the greatest benefits of using nodejs in the first place on a crummy server.

这篇关于在Node.js的前反向代理的优势的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆