Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
NodeJS virtual hosting server
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
gatedata
lib
LICENSE
README.md
package.json

README.md

GateKeeper

NodeJS virtual hosting server.

What does it solve?

Ever had 1 server and wanted to deploy 2 NodeJS webapps on it but you also had an Apache server already running on it?

Well GateKeeper solves that problem!

How does GateKeeper solve that?

with GateKeeper you map the a domain to an app or proxy to a different server or port.
Setting it up is really simple!

How to set it up?

Let's start with the basics!

npm i -g gatekeeperjs

Well now we've done that, we need to set up an GateData folder with our config and domains.

The GateData folder

A GateData folder looks for example like this:

|- config.json  
|  
|-- domains  
  |  
  |-- example.com  
  | |  
  | |- main.js  
  |  
  |-- proxy.example.com  
    |  
    |- main.js

The config.json is a really simple JSON file.
which in most cases would look like this:

{
    "port":80
}

The domains folder is the folder where all the magic happens.
Each folder inside that folder should represent the dns of the app in it.
So in the example above I host the websites proxy.example.com and example.com. In each domain folder should be an main.js, which will be executed when your domain is initialized.

the main.js looks for example like this:

module.exports = {
    request:function(req,resp){
        resp.end("Wow!\n\nyou visited my domain!");
    }   
};

The request function is exact the same as http.createServer().on("request",function(){}).

So porting code to the GateKeeper is done in no time!

But what about that Apache server?

Well that Apache server is easily installed too via a reverse proxy!

just change your main.js in your domain folder to:

module.exports = {
    type:"proxy",
    port:myDestinationPort, //defaults to port 80
    host:myDestHost // defaults to "127.0.0.1"
};

Happy proxying!

Starting the server

Starting is rather easy

gatekeeper runat [path to your GateData folder]

Still need help?

I hope that was all the info you really needed!
If you still can't figure it out:

Contact me at he@eaterofcorps.es

Something went wrong with that request. Please try again.