LearnBoost / cluster

Node.JS multi-core server manager with plugins support.
http://learnboost.github.com/cluster
MIT License
2.29k stars 159 forks source link

Use of server depending on the http host #157

Closed AndreasMadsen closed 12 years ago

AndreasMadsen commented 12 years ago

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.

tj commented 12 years ago

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

AndreasMadsen commented 12 years ago

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

tj commented 12 years ago

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

AndreasMadsen commented 12 years ago

I have reviewed both of them.

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

AndreasMadsen commented 12 years ago

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.

tj commented 12 years ago

awesome :)