Skip to content

Commit

Permalink
removed redis backend dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
manast committed Aug 27, 2014
1 parent eb75f0f commit 149a573
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 17 deletions.
1 change: 0 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
module.exports = require('./lib/proxy');
module.exports.redis = require('./lib/redis-backend');
34 changes: 21 additions & 13 deletions lib/proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,39 +7,47 @@ var
parse_url = require('url').parse,
path = require('path'),
_ = require('lodash'),
redisBackend = require('./redis-backend'),
bunyan = require('bunyan');

var log = bunyan.createLogger({
name: 'redbird',
});

function ReverseProxy(backend, opts){
backend = backend || redisBackend();
// TODO: If no backend is specified just instantiate a static proxy.

function ReverseProxy(opts){
opts = opts || {};

opts.port = opts.port || 8080;

if(!(this instanceof ReverseProxy)){
return new ReverseProxy(backend, opts);
return new ReverseProxy(opts);
}

//
// Create a proxy server with custom application logic
// Routing table.
//
var proxy = httpProxy.createProxyServer();
var routing = this.routing = {};

//
// Routing table.
// Create a proxy server with custom application logic
//
var routing = this.routing = {};
var proxy = this.proxy = httpProxy.createProxyServer();

var server = require('http').createServer(function(req, res) {
var target = getTarget(routing, req);
//
// Standard HTTP Proxy Server.
//
var server = this.server = require('http').createServer(function(req, res) {
var src = getSource(req);
var target = getTarget(src, routing, req);
if(target){
proxy.web(req, res, { target: target });
//
// Automatically redirect to the HTTPS proxy if there are
// certificates for this hostname.
//
if(certs[src]){
redirectToHttps(req, res, target, opts.ssl);
}else{
proxy.web(req, res, {target: target});
}
}else {
notFound(res);
}
Expand Down
4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "redbird",
"version": "0.1.7",
"version": "0.1.8",
"description": "A reverse proxy with support for dynamic tables based on etcd",
"main": "index.js",
"scripts": {
Expand All @@ -24,10 +24,8 @@
"dependencies": {
"bluebird": "^2.2.2",
"bunyan": "^1.0.0",
"hiredis": "^0.1.17",
"http-proxy": "^1.2.0",
"lodash": "^2.4.1",
"redis": "^0.12.1",
"valid-url": "^1.0.9"
}
}

0 comments on commit 149a573

Please sign in to comment.