From f5c7600ac003bf29c2ce03438c2febee984b5460 Mon Sep 17 00:00:00 2001 From: Graham Leggett Date: Tue, 18 Sep 2018 21:17:53 +0000 Subject: [PATCH] mod_proxy_hcheck: take balancer's SSLProxy* directives into account. trunk patch: http://svn.apache.org/r1836276 2.4.x patch: svn merge -c 1836276 ^/httpd/httpd/trunk . +1: jim, ylavic, minfrin git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1841261 13f79535-47bb-0310-9956-ffa450edef68 --- CHANGES | 3 ++ STATUS | 5 ---- modules/proxy/mod_proxy_hcheck.c | 48 ++++++++++++++++++++------------ 3 files changed, 33 insertions(+), 23 deletions(-) diff --git a/CHANGES b/CHANGES index 602ebd4873c..7443f4d5ecf 100644 --- a/CHANGES +++ b/CHANGES @@ -3,6 +3,9 @@ Changes with Apache 2.4.36 Changes with Apache 2.4.35 + *) mod_proxy_hcheck: take balancer's SSLProxy* directives into account. + [Jim Jagielski] + *) mod_status, mod_echo: Fix the display of client addresses. They were truncated to 31 characters which is not enough for IPv6 addresses. This is done by deprecating the use of the 'client' field and using diff --git a/STATUS b/STATUS index d01a468b33e..11d1d0291f5 100644 --- a/STATUS +++ b/STATUS @@ -124,11 +124,6 @@ RELEASE SHOWSTOPPERS: PATCHES ACCEPTED TO BACKPORT FROM TRUNK: [ start all new proposals below, under PATCHES PROPOSED. ] - *) mod_proxy_hcheck: take balancer's SSLProxy* directives into account. - trunk patch: http://svn.apache.org/r1836276 - 2.4.x patch: svn merge -c 1836276 ^/httpd/httpd/trunk . - +1: jim, ylavic, minfrin - PATCHES PROPOSED TO BACKPORT FROM TRUNK: diff --git a/modules/proxy/mod_proxy_hcheck.c b/modules/proxy/mod_proxy_hcheck.c index 0265b4ab979..0ee68452650 100644 --- a/modules/proxy/mod_proxy_hcheck.c +++ b/modules/proxy/mod_proxy_hcheck.c @@ -70,6 +70,7 @@ typedef struct { typedef struct { apr_pool_t *ptemp; sctx_t *ctx; + proxy_balancer *balancer; proxy_worker *worker; proxy_worker *hc; apr_time_t now; @@ -330,16 +331,22 @@ static const char *set_hc_tpsize (cmd_parms *cmd, void *dummy, const char *arg) * Use our short-lived pool for bucket_alloc so that we can simply move * buckets and use them after the backend connection is released. */ -static request_rec *create_request_rec(apr_pool_t *p, conn_rec *conn, const char *method) +static request_rec *create_request_rec(apr_pool_t *p, server_rec *s, + proxy_balancer *balancer, + const char *method) { request_rec *r; - apr_bucket_alloc_t *ba; + r = apr_pcalloc(p, sizeof(request_rec)); - ba = apr_bucket_alloc_create(p); r->pool = p; - r->connection = conn; - r->connection->bucket_alloc = ba; - r->server = conn->base_server; + r->server = s; + + r->per_dir_config = r->server->lookup_defaults; + if (balancer->section_config) { + r->per_dir_config = ap_merge_per_dir_configs(r->pool, + r->per_dir_config, + balancer->section_config); + } r->proxyreq = PROXYREQ_RESPONSE; @@ -356,16 +363,9 @@ static request_rec *create_request_rec(apr_pool_t *p, conn_rec *conn, const char r->trailers_out = apr_table_make(r->pool, 1); r->notes = apr_table_make(r->pool, 5); - r->kept_body = apr_brigade_create(r->pool, r->connection->bucket_alloc); r->request_config = ap_create_request_config(r->pool); /* Must be set before we run create request hook */ - r->proto_output_filters = conn->output_filters; - r->output_filters = r->proto_output_filters; - r->proto_input_filters = conn->input_filters; - r->input_filters = r->proto_input_filters; - r->per_dir_config = r->server->lookup_defaults; - r->sent_bodyct = 0; /* bytect isn't for body */ r->read_length = 0; @@ -379,9 +379,6 @@ static request_rec *create_request_rec(apr_pool_t *p, conn_rec *conn, const char */ r->used_path_info = AP_REQ_DEFAULT_PATH_INFO; - r->useragent_addr = conn->client_addr; - r->useragent_ip = conn->client_ip; - /* Time to populate r with the data we have. */ r->method = method; @@ -403,6 +400,19 @@ static request_rec *create_request_rec(apr_pool_t *p, conn_rec *conn, const char return r; } +static void set_request_connection(request_rec *r, conn_rec *conn) +{ + conn->bucket_alloc = apr_bucket_alloc_create(r->pool); + r->connection = conn; + + r->kept_body = apr_brigade_create(r->pool, conn->bucket_alloc); + r->output_filters = r->proto_output_filters = conn->output_filters; + r->input_filters = r->proto_input_filters = conn->input_filters; + + r->useragent_addr = conn->client_addr; + r->useragent_ip = conn->client_ip; +} + static void create_hcheck_req(wctx_t *wctx, proxy_worker *hc, apr_pool_t *p) { @@ -752,13 +762,14 @@ static apr_status_t hc_check_http(baton_t *baton) return backend_cleanup("HCOH", backend, ctx->s, status); } + r = create_request_rec(ptemp, ctx->s, baton->balancer, wctx->method); if (!backend->connection) { - if ((status = ap_proxy_connection_create("HCOH", backend, NULL, ctx->s)) != OK) { + if ((status = ap_proxy_connection_create_ex("HCOH", backend, r)) != OK) { return backend_cleanup("HCOH", backend, ctx->s, status); } } + set_request_connection(r, backend->connection); - r = create_request_rec(ptemp, backend->connection, wctx->method); bb = apr_brigade_create(r->pool, r->connection->bucket_alloc); if ((status = hc_send(r, wctx->req, bb)) != OK) { @@ -942,6 +953,7 @@ static apr_status_t hc_watchdog_callback(int state, void *data, baton = apr_palloc(ptemp, sizeof(baton_t)); baton->ctx = ctx; baton->now = now; + baton->balancer = balancer; baton->worker = worker; baton->ptemp = ptemp; baton->hc = hc_get_hcworker(ctx, worker, ptemp); -- 2.47.3