added error handling on http-proxy instance

This commit is contained in:
tigerbot 2017-06-09 11:58:43 -06:00
parent 78da05b630
commit f569391cd9
1 changed files with 7 additions and 0 deletions

View File

@ -204,6 +204,13 @@ module.exports.create = function (deps, conf, greenlockMiddleware) {
, toProxy: true
});
proxy.on('error', function (err, req, res) {
res.statusCode = 502;
res.setHeader('Connection', 'close');
res.setHeader('Content-Type', 'text/html');
res.end(require('../proxy-conn').getRespBody(err, conf.debug));
});
proxyServer = http.createServer(function (req, res) {
proxy.web(req, res, req.connection.proxyOpts);
});