From 3b74625ad353ee901fce7c2e2dc0cace2a6241e7 Mon Sep 17 00:00:00 2001 From: Datong Sun Date: Fri, 23 Jun 2017 19:02:26 -0700 Subject: [PATCH] feature: added the balancer_status_code patch to the nginx core to allow returning arbitrary HTTP status codes inside upstream balancers. Signed-off-by: Yichun Zhang (agentzh) --- .../nginx-1.11.2-balancer_status_code.patch | 27 +++++++++++++++++++ util/mirror-tarballs | 7 +++++ 2 files changed, 34 insertions(+) create mode 100644 patches/nginx-1.11.2-balancer_status_code.patch diff --git a/patches/nginx-1.11.2-balancer_status_code.patch b/patches/nginx-1.11.2-balancer_status_code.patch new file mode 100644 index 0000000..ea40525 --- /dev/null +++ b/patches/nginx-1.11.2-balancer_status_code.patch @@ -0,0 +1,27 @@ +diff --git a/src/http/ngx_http_upstream.c b/src/http/ngx_http_upstream.c +index 0f6b3ae..56d44fc 100644 +--- a/src/http/ngx_http_upstream.c ++++ b/src/http/ngx_http_upstream.c +@@ -1368,6 +1368,11 @@ ngx_http_upstream_connect(ngx_http_request_t *r, ngx_http_upstream_t *u) + return; + } + ++ if (rc >= NGX_HTTP_SPECIAL_RESPONSE) { ++ ngx_http_upstream_finalize_request(r, u, rc); ++ return; ++ } ++ + u->state->peer = u->peer.name; + + if (rc == NGX_BUSY) { +diff --git a/src/http/ngx_http_upstream.h b/src/http/ngx_http_upstream.h +index b288f28..9b60e12 100644 +--- a/src/http/ngx_http_upstream.h ++++ b/src/http/ngx_http_upstream.h +@@ -418,5 +418,6 @@ extern ngx_module_t ngx_http_upstream_module; + extern ngx_conf_bitmask_t ngx_http_upstream_cache_method_mask[]; + extern ngx_conf_bitmask_t ngx_http_upstream_ignore_headers_masks[]; + ++#define HAVE_BALANCER_STATUS_CODE_PATCH + + #endif /* _NGX_HTTP_UPSTREAM_H_INCLUDED_ */ diff --git a/util/mirror-tarballs b/util/mirror-tarballs index 2f00c27..ec41a5c 100755 --- a/util/mirror-tarballs +++ b/util/mirror-tarballs @@ -55,6 +55,13 @@ else fi fi +answer=`$root/util/ver-ge "$main_ver" 1.11.2` +if [ "$answer" = "Y" ]; then + echo "$info_txt applying the balancer_status_code patch" + patch -p1 < $root/patches/nginx-$main_ver-balancer_status_code.patch || exit 1 + echo +fi + answer=`$root/util/ver-ge "$main_ver" 1.11.2` if [ "$answer" = "Y" ]; then echo "$info_txt applying the builtin_error_page_footer patch"