Skip to content

Instantly share code, notes, and snippets.

@elbart
Forked from jb55/gist:945731
Created April 28, 2011 06:30
Show Gist options
  • Save elbart/945901 to your computer and use it in GitHub Desktop.
Save elbart/945901 to your computer and use it in GitHub Desktop.
replace nginx with connect
var connect = require('connect')
, proxy = require('http-proxy')
function redirect(loc) {
return connect.createServer(function(req, res){
res.writeHead(301, { "Location": loc });
res.end();
});
}
connect(
connect.vhost('stuff.jb55.com', connect.createServer(connect.static(__dirname + "/stuff"))),
connect.vhost('www.jb55.com', redirect("http://jb55.com/")),
connect.vhost('jb55.com', connect.createServer(connect.static(__dirname + "/public"))),
connect.vhost('somesite.jb55.com', proxy.createServer(8083, 'localhost'))
).listen(80);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment