LearnBoost / cluster

Node.JS multi-core server manager with plugins support.

Home Page:http://learnboost.github.com/cluster

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Use of server depending on the http host

AndreasMadsen opened this issue · comments

The bigest problem I face with node.js every day is that it's very difficult to have more that one domain on the same server, without mixing the server.js files.

I believe we could adapt cluster to mangage this issue, the API cloud be very simple, something like:

cluster('./app')
  .use(cluster.cli())
  .httpListen("example.com", 80);

However I am not a network expert, so I'm hoping that someone cloud give me some insite or perhaps make a pull request.

you can already listen on a domain, or are you looking for "virtual host"-like functionality?

Yes I'm looking for at "virtual host" system.

ah, well I would suggest (if you want to stick with node tools) to use cluster+node-http-proxy, or alternatively use Connect's vhost() middleware+cluster which essentially just routes by domain, slightly different benefits from each

I have reviewed both of them.

  • Connect-vhost seams to make the http routing very transparent, however it do not support independent process since you have to add the httpServer instance directly to the connect-core.
  • Node-http-proxy do support independent process, but are sending the host-address by using http-headers with makes it less transparent.

Cluster seams to manage the host-address transparently issue by using the net.listenFD method. Do you know if this also can be used in a socket-connection where a part of the incoming data (http-host-header) already have been send by the client and read by a 'http-proxy-server'.

I have created a plugin to cluster there use the node-http-proxy module. It can be found on: https://github.com/AndreasMadsen/cluster-vhost

I will make a README pull request when I have documented the configuration file.

awesome :)