Created
November 15, 2012 04:46
-
-
Save ryanstevens/4076718 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var proxyServer = httpProxy.createServer(function (req, res, proxy) { | |
//look for anything with "socket" in the sub-domain and route to node, otherwise route to php | |
var host = req.headers.host, | |
target = routes.getTarget([host]); | |
if (!target) { | |
logger.error("No route for " + host+", cannot serve "+req.url); | |
res.end(); | |
return; | |
} | |
logger.info("Routing "+host+req.url+" to "+target.host+":"+target.port) | |
proxy.proxyRequest(req, res, { | |
host: target.host, | |
port: target.port | |
}) | |
}).listen(props.get('ports:http')); | |
//only SSL terminate if its actually assigned to 443 | |
if (props.get('ports:https') === 443) { | |
//terminate SSL and proxy | |
httpProxy.createServer(props.get('ports:http'), props.get('domain'), { | |
https: { | |
key: fs.readFileSync(__dirname + '/certs/'+props.get('certFile')+'.key', 'utf8'), | |
cert: fs.readFileSync(__dirname + '/certs/'+props.get('certFile')+'.crt', 'utf8') | |
} | |
}).listen(props.get('ports:https')); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment