Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Node.js as an application container

Tags:

node.js

Apache and Node.js have something in common. The more I use Node.js, the more I like Node.js; similarly, more I use Apache, the more I like Node.js.

One good thing about Apache though, it can do a lot of things through the same port. PHP, Python, Perl, different apps, different paths, the whole magilla. Node.js doesn't do that, and it isn't supposed to but I would like to do something similar.

I would like to give it a list of URL-prefixes (or regexps ideally) and enough information to, if it receives a request matching a particular prefix, it passes off the request to a subordinate instance running a specified script (and it will start such an instance if it hasn't already, and close it down when doing so seems prudent). Basically, I want nodejs-proxy and cluster cooperating. With it, I could run several apps together on the same machine through port 80.

This seems pretty easy and very useful and I was about to just write it myself when it occurred to me, "This seems pretty easy and very useful -- probably someone has already written it!" Any suggestions?

like image 810
Michael Lorton Avatar asked Aug 29 '11 22:08

Michael Lorton


1 Answers

Node.js doesn’t have any built-in ability to route requests to different applications, but frameworks like this are in development.

Nodejitsu’s Haibu comes to mind — it manages child processes for each application and uses node-http-proxy to route the requests.

like image 75
s4y Avatar answered Sep 21 '22 14:09

s4y