Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
900 views
in Technique[技术] by (71.8m points)

apache - Advantages of a reverse proxy in front of Node.JS

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

Thank you.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.

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

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.

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...