From f569391cd9b9019d11289f48bd251d0e980c0372 Mon Sep 17 00:00:00 2001 From: tigerbot Date: Fri, 9 Jun 2017 11:58:43 -0600 Subject: [PATCH] added error handling on http-proxy instance --- lib/modules/http.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/modules/http.js b/lib/modules/http.js index 9b80437..4956ab5 100644 --- a/lib/modules/http.js +++ b/lib/modules/http.js @@ -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); });