0.0.10 • Published 10 years ago

reproxy v0.0.10

Weekly downloads
13
License
MIT
Repository
github
Last release
10 years ago

Reproxy

Reverse proxy for node.js applications.

Instalaltion

npm install reproxy

Access the the library like this:

var reproxy = require('reproxy');

Usage

Overview

To use reproxy you must implement your own reproxy adapter (or use existing ones). Reproxy doesn't come with any adapters, so this is will guide you for creating a simple one.

1. Creating a new adapter

var MyAdapter = Object.create(reproxy.Adapter);

1.1. Implement adapter's initialization method

MyArray.prototype.init = function() {
	console.log("Adapter is being initialized.");
};

1.2. Implement adapter's fetch method

MyAdapter.prototype.fetch = function() {
	return {
		"app1.vcap.me" : { host: 'localhost', port: 3000 },
		"app2.vcap.me" : { host: 'localhost', port: 3001 }
	};
};	

2. Running the proxy

// Creates the proxy using our adapter.
var proxy = new reproxy.Proxy(new MyAdapter());

2.1. Adding custom error handler

proxy.on('error', function(request, response, websocket) {
	response.writeHead(500);
	response.write("Cannot find routes for domain '" + request.headers.host + "'");
});

2.1. Adding transfer monitor

proxy.on('bandwidth', function(host, request, response) {
	console.log('Proxy status for ' + host);
	console.log('  Request:  ' + request + ' bytes.');
	console.log('  Response: ' + response + ' bytes.');
	console.log('');
});

2.2. Run the proxy

proxy.run(80);
0.0.10

10 years ago

0.0.9

10 years ago

0.0.8

10 years ago

0.0.7

10 years ago

0.0.6

10 years ago

0.0.5

10 years ago

0.0.4

10 years ago

0.0.2

10 years ago

0.0.1

10 years ago