Skip to content

Commit

Permalink
Updated proxy server to not accept requests there don't match any kno…
Browse files Browse the repository at this point in the history
…wn hostname
  • Loading branch information
AndreasMadsen committed Oct 25, 2011
1 parent f46f879 commit 3237859
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/http-proxy.js 100644 → 100755
Expand Up @@ -65,14 +65,22 @@
//Proxy HTTP(S) requests
exports = module.exports = httpModule.createServer(function (req, res) {

console.log("got request");

var host = req.headers.host;
host = (host.indexOf(":") === -1 ? host : host.substr(0, host.indexOf(":")));

//Store the host header
req.headers['x-forwarded-host'] = req.headers.host;

//If virtual host is missing destroy the connection
if (vhost[host] === undefined) {
res.connection.destroy();
}
//Proxy the main request
vhost[host].proxyRequest(req, res);
else {
vhost[host].proxyRequest(req, res);
}
});

exports.on('upgrade', function (req, socket, head) {
Expand Down

0 comments on commit 3237859

Please sign in to comment.