virtual host setup made easy
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.
##How to use
npm install cluster-vhost
var cluster = require'cluster'vhost = require'cluster-vhost';vhostuse'example.org';vhoston'done'console.log"You can now access your app, by opening in your browser";;vhoston'error'console.error'not good';throw err;;//Start clusterclusterfork;
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.
After the line
localhost 127.0.0.1 create a new line with the text
The result will be:
localhost 127.00.1exampleorg 127.00.1
##Configure the proxy-server
###Creating the file
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.
var cluster = require"cluster"vhost = require"cluster-vhost";vhostconfig'./config.json';vhostuse'example.org';//Start clusterclusterautoFork;
###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"
##License WebNodes use the "GPL License Version 3"