cluster-vhost is a module there allow you to use as many virtual host domains as you which. It is often used in combination with the cluster module but it is not required.
This module require node 0.7.0-pre or higher since the 0.6.0 cluster module isn't sophisticated enough.
- Ridiculously easy to use
- Support http to http proxy
- Support https to http proxy
How to use
npm install cluster-vhost
var cluster =vhost = ;vhost;vhost;vhost;//Start clustercluster;
You can now access your site on
http://example.org:8001. Note that if you
started your application as root you can access using
Configure host file
You will need to edit you hosts file to redirect example.org to you own computer.
First open the file in you text editor.
- On mac and linux you will find a file named
- On windows you will find a file named
After the line
localhost 127.0.0.1 create a new line with the text
The result will be:
localhost 127001exampleorg 127001
Configure the proxy-server
You do not need to create a configuration file, if none is found the module will use default values.
cluster-vhost can be configured with a
config.json file. The first
step is to create it the in the right directory. This module will search
config.json in its own directory and then go up in the folder tree
until it finds a
Example: if you have your websites in
~/Sites/ and typed
npm install cluster-vhost
here, you will have it in a
cluster-vhost will then search for
config.json file in the following directories:
Alternative configuration method
Instead of searching for
config.json you can also configure the
proxy-server by using the
vhost.config() method accepts a filepath or an object.
- If a filepath is given it must contain a valid json string.
- If a object is given it must contain a valid json object.
var cluster =vhost = ;vhost;vhost;//Start clustercluster;
Writing the file
node-module may also use your a
cluster-vhost properties should be placed in a
There are several properties you can set, all will fallback to its
default value if not set.
//Because other modules may use a config.json file place you options insite a vhost obejct."vhost" ://You can specify on what the virtual host router should listen on.//You can also set it to false if you don't want it to listen for http requests."http" ://By default it will listen for http requests on 127.0.0.1:8001"port" : 8001"host" : "127.0.0.1"//You can also use a unix path to listen on, but this will only work if no port property is set."path" : "./custom/unix/http.sock"//The ssl property is a path to a directory containing a key.pem and a cert.pem file.//By default the ssl property is set to undefined."ssl" : "./Sites/ssl/"//If and only if a ssl property is set you can use https, else it will fallback to false.//You can in this object specify what the virtual host router should listen on, just like the http object."https" ://By default if the ssl property is set it will listen for https requests on 127.0.0.1:8002"port" : 8002"host" : "127.0.0.1"//Again you can also use a unix path"path" : "./custom/unix/https.sock"
- http-proxy-server (nodejitsu) https://github.com/nodejitsu/node-http-proxy
WebNodes use the "GPL License Version 3"