Skip to content

omsmith/simple-reverse-proxy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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);
});

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published