Nginx would log status to 200 after response header had sent when upstream prematurely closed connection
I think nginx should log status to 502, even though client recv 200
static u_char *
ngx_http_log_status(ngx_http_request_t *r, u_char *buf, ngx_http_log_op_t *op)
{
ngx_uint_t status;
if (r->err_status) {
status = r->err_status;
} else if (r->headers_out.status) {
status = r->headers_out.status;
} else if (r->http_version == NGX_HTTP_VERSION_9) {
status = 9;
} else {
status = 0;
}
return ngx_sprintf(buf, "%03ui", status);
}
r->err_status should be set in this situation