Skip to content

Instantly share code, notes, and snippets.

@jb55
Created April 28, 2011 03:13
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save jb55/945731 to your computer and use it in GitHub Desktop.
Save jb55/945731 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