Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why do we need apache under Node.js express web framework?

I am going to deploy my node.js application.

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

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

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.

Kit

like image 796
TheOneTeam Avatar asked Feb 15 '12 04:02

TheOneTeam


1 Answers

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.

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

like image 72
Mâtt Frëëman Avatar answered Oct 12 '22 14:10

Mâtt Frëëman