<div dir="ltr">Hi,<div><br></div><div>It seems to we can't check a request whether used upstream keepalive, so I add </div><div>the following code with an additional variable named $upstream_keepalive.</div><div><br></div><div>
<p class=""><span class="">static ngx_int_t</span></p>
<p class=""><span class="">ngx_http_upstream_keepalive_variable(ngx_http_request_t *r, ngx_http_variable_value_t *v,</span></p>
<p class=""><span class=""> uintptr_t data)</span></p>
<p class=""><span class="">{</span></p>
<p class=""><span class=""> if (r->upstream_states == NULL || r->upstream_states->nelts == 0 || r->upstream->peer.cached == 0) {</span></p>
<p class=""><span class=""> v->data = (u_char *) "0";</span></p>
<p class=""><span class=""></span><br></p>
<p class=""><span class=""> } else {</span></p>
<p class=""><span class=""> v->data = (u_char *) "1";</span></p>
<p class=""><span class=""> }</span></p>
<p class=""><span class=""></span><br></p>
<p class=""><span class=""> v->len = 1;</span></p>
<p class=""><span class=""> v->valid = 1;</span></p>
<p class=""><span class=""> v->no_cacheable = 0;</span></p>
<p class=""><span class=""> v->not_found = 0;</span></p>
<p class=""><span class=""></span><br></p>
<p class=""><span class=""> return NGX_OK;</span></p>
<p class=""><span class="">}</span></p><p class=""><span class=""><br></span></p><p class=""><span class="">Help check it, thanks a lot!</span></p><p class=""><span class=""><br></span></p><p class=""><span class="">B.R.</span></p></div></div>