--- mod_proxy.c.orig Mon Feb 15 16:06:14 2016 +++ mod_proxy.c Mon Feb 15 16:07:46 2016 @@ -1185,6 +1185,12 @@ worker->s->error_time = apr_time_now(); } } + else if (access_status == HTTP_GATEWAY_TIME_OUT) { + if (balancer && balancer->failontimeout) { + worker->s->status |= PROXY_WORKER_IN_ERROR; + worker->s->error_time = apr_time_now(); + } + } else { /* Unrecoverable error. * Return the origin status code to the client. --- mod_proxy_ajp.c.orig Mon Feb 15 15:04:10 2016 +++ mod_proxy_ajp.c Mon Feb 15 16:05:18 2016 @@ -193,6 +193,7 @@ apr_off_t content_length = 0; int original_status = r->status; const char *original_status_line = r->status_line; + int is_timeout = 0; if (psf->io_buffer_size_set) maxsize = psf->io_buffer_size; @@ -590,6 +591,9 @@ status = ajp_read_header(conn->sock, r, maxsize, (ajp_msg_t **)&(conn->data)); if (status != APR_SUCCESS) { + if (APR_STATUS_IS_TIMEUP(status)) { + is_timeout = 1; + } backend_failed = 1; ap_log_rerror(APLOG_MARK, APLOG_DEBUG, status, r, APLOGNO(00889) "ajp_read_header failed"); @@ -675,7 +679,11 @@ */ rv = HTTP_SERVICE_UNAVAILABLE; } else { - rv = HTTP_INTERNAL_SERVER_ERROR; + if (is_timeout == 1) { + rv = HTTP_GATEWAY_TIME_OUT; + } else { + rv = HTTP_INTERNAL_SERVER_ERROR; + } } } else if (client_failed) {