increase request counter before an upstream cleanup because the cleanup decreases the counter via ngx_http_finalize_request(r, NGX_DONE), the bug was introduced in r3050
diff --git a/src/http/ngx_http_upstream.c b/src/http/ngx_http_upstream.c index 6f15c04..5186b80 100644 --- a/src/http/ngx_http_upstream.c +++ b/src/http/ngx_http_upstream.c
@@ -363,6 +363,7 @@ u = r->upstream; if (u && u->cleanup) { + r->main->count++; ngx_http_upstream_cleanup(r); *u->cleanup = NULL; }