Node.js express web 框架下为什么需要apache?

Node.js express web 框架下为什么需要apache?

问题描述:

我将部署我的 node.js 应用程序.

I am going to deploy my node.js application.

我只能使用纯 node.js 启动我自己的 Web 应用程序.

I can start my own web application with purely node.js only.

但是我的 fd 告诉我最好在 apache 或 nginx 下为该 Web 应用程序提供服务.

But my fd told me that it is better to serve that web app under apache or nginx.

任何人都有这样的经验,为什么我们需要 apache,因为我只能在 node.js+ express 上启动我的 web 应用程序?

Anyone have such kind of experience, why do we need apache as I can start my web app on node.js+ express only?

我想了解更多关于部署的知识.感谢您的帮助.

I would like to know more on deployment knowledges. Thanks for any help.

套件

将 Apache 置于 Node 前面在新建应用程序中并不常见.我可以同意的唯一情况是,如果您的公司在前端对基于 Apache 的基础设施(监控/安全/路由/缓存等)进行了现有投资,并且系统管理员坚持此设置.

Putting Apache in front of Node is not typical in a greenfield app. The only case I can grant to this is if your company has an existing investment in an Apache based infrastructure (monitoring/security/routing/caching etc..) on the frontend and the sysadmin insist on this setup.

有些人更喜欢将 nginx 或 haproxy 放在前面来管理路由规则,这样他们就可以将静态文件(资产)的请求从 Node.js 引导出去(node.js 在处理静态文件时并不总是表现良好),或者做花哨的负载平衡或故障转移.在 0.2.x 等早期……甚至 Ryan Dahl 也提倡在 Node.js 前面运行一些东西,主要是为了安全;虽然,我认为没有发现任何重大问题.我个人在 Node.js 前面运行 nginx,因为我们有几个站点和服务访问前端共享 IP,我们将这些 IP 代理回侦听不同内部端口的各个节点实例.

Some folks prefer to put nginx or haproxy in front to manage routing rules, so they can channel requests for static files (assets) away from Node.js (node.js wasn't always performant when handling static files), or do fancy load balancing or failover. In the early days of 0.2.x etc... even Ryan Dahl advocated running something in front of Node.js for security mainly; although, I don't think any significant issues were discovered. I personally run nginx in front of Node.js as we have several sites and services that hit the frontend shared IP which we proxy back to various node instances listening on different internal ports.

Nginx 比 Apache 更适合,因为它是轻量级的,单线程与每个请求的 Apache 线程(在大多数正常设置中).但是现在甚至有一个可靠的(node-http-proxy 除外)基于 Node.JS 的前端代理 http://www.github.com/substack/bouncy 其中一位名人 node.js 开发人员使用/将使用它来前端他的 PaaS.

Nginx is better suited than Apache as it is light and single threaded vs Apache thread per request (in most normal setups). But nowadays there's even a reliable (node-http-proxy excluded) frontend Node.JS based proxy http://www.github.com/substack/bouncy which one of the celebrity node.js developers uses/will-use to frontend his PaaS.