From d6b495f2a71fb8a452f224c9fa33774b8387123b Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Tue, 19 Aug 2014 23:41:53 +0900 Subject: [PATCH] nghttpx: Returns 503 if downstream connect fail for https upstream --- src/shrpx_https_upstream.cc | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/shrpx_https_upstream.cc b/src/shrpx_https_upstream.cc index ef867eee..f41f682e 100644 --- a/src/shrpx_https_upstream.cc +++ b/src/shrpx_https_upstream.cc @@ -375,7 +375,16 @@ int HttpsUpstream::on_read() handler->set_should_close_after_write(true); pause_read(SHRPX_MSG_BLOCK); - if(error_reply(400) != 0) { + unsigned int status_code; + + if(downstream && downstream->get_request_state() == + Downstream::CONNECT_FAIL) { + status_code = 503; + } else { + status_code = 400; + } + + if(error_reply(status_code) != 0) { return -1; }