繁体   English   中英

对于在 Node.JS 上运行的 SaaS,是否需要 Web 服务器 (nginx) 或清漆作为反向代理?

[英]For a SaaS running on Node.JS, is a web-server (nginx) or varnish necessary as a reverse proxy?

对于在 Node.JS 上运行的 SaaS,是否需要 Web 服务器?

如果是,是哪一个,为什么?

只使用节点有什么缺点? 它的作用是只处理 CRUD 请求并为客户端提供 JSON 以解析日期(如 Gmail)。

“是否需要网络服务器”?

从技术上讲,没有。 实际上,是的,通常使用单独的 web 服务器,这是有充分理由的。

In this talk by Ryan Dahl in May 2010 , at 37'30" he states that he recommends running node.js behind a reverse proxy or web server for "security reasons". To elaborate on that, hardened web servers like nginx or apache have had their TCP stacks evolve for a long time in terms of stability and security. Node.js is not at that same level yet. Thus, since putting node.js behind nginx is easy, doesn't have many negative consequences, and in theory increases the security of your deployment某种程度上,这是一个不错的选择。在某个时间点,node.js 可能被官方视为“准备好进行实时直接 Internet 连接”,但请等待 Ryan/Joyent 对此发表一些声明。

其次,绑定到 sub-1024 端口(如 80 和 443)需要进程是 root。 nginx 和其他人会自动以 root 身份处理绑定,然后将权限丢弃到更安全的用户帐户(通常是 www-data 或没人)。 尽管 node.js 在process模块中有系统调用包装器以使用setgidsetuid删除 root 权限,但 AFAIK 除了自己编码之外,节点社区还没有看到这样做的约定。 此讨论中有关此主题的更多信息。

第三,web 服务器擅长虚拟托管,通常您可以做一些方便的事情(URL 重写等),需要在 node.js 中进行自定义编码才能实现其他目的。

第四,nginx 非常擅长提供 static 文件。 比 node.js 好(至少现在稍微好一点)。 随着时间的推移,这一点可能变得越来越不重要,但在我看来,传统的 static 文件 web 服务器和 web 应用程序服务器仍然具有不同的角色和用途。

“如果是,是哪一个,为什么”?

nginx 因为它比 apache 具有出色的性能和更简单的配置。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM