1.0.2 • Published 9 years ago

simple-reverse-proxy v1.0.2

Weekly downloads
114
License
MIT
Repository
github
Last release
9 years ago

simple-reverse-proxy

A simple reverse proxy that takes care of managing upstream servers.

Built with node-http-proxy.

Example

var SimpleReverseProxy = require('simple-reverse-proxy');

new SimpleReverseProxy([
		'http://localhost:10001',
		'http://localhost:10002',
		'http://localhost:10003'
	], {
		agent: false
	})
	.listen(10000);

[10001, 10002, 10003].forEach(function (port) {
	require('http')
		.createServer(function (req, res) {
			res.statusCode = 200;
			res.end();

			console.log(port);
		})
		.listen(port);
});

Upgrading from v0.0.4

Previous versions of simple-reverse-proxy provided a path-based router which has been removed in v1.0.0. This functionality can be replaced with simple-path-router. Also see simple-virtual-hosts to add host based routing/virtual hosts.

var SimpleReverseProxy = require('simple-reverse-proxy'),
	SimplePathRouter = require('simple-path-router');

new SimplePathRouter()
	.when('/', new SimpleReverseProxy(['http://localhost:10001']))
	.when('/api', new SimpleReverseProxy(['http://localhost:10002', 'http://localhost:10003']))
	.listen(10000);

[10001, 10002, 10003].forEach(function (port) {
	require('http')
		.createServer(function (req, res) {
			res.statusCode = 200;
			res.end();

			console.log(port);
		})
		.listen(port);
});
1.0.2

9 years ago

1.0.1

10 years ago

1.0.0

10 years ago

0.0.4

10 years ago

0.0.3

10 years ago

0.0.2

10 years ago