diff --git a/doc/configuration.txt b/doc/configuration.txt index c16137db5..89bdf986a 100644 --- a/doc/configuration.txt +++ b/doc/configuration.txt @@ -12099,10 +12099,10 @@ Please refer to the table below for currently defined variables : | | %fi | frontend_ip (accepting address) | IP | | | %fp | frontend_port (accepting address) | numeric | | | %ft | frontend_name_transport ('~' suffix for SSL) | string | - | H | %hr | captured_request_headers default style | string | - | H | %hrl | captured_request_headers CLF style | string list | - | H | %hs | captured_response_headers default style | string | - | H | %hsl | captured_response_headers CLF style | string list | + | | %hr | captured_request_headers default style | string | + | | %hrl | captured_request_headers CLF style | string list | + | | %hs | captured_response_headers default style | string | + | | %hsl | captured_response_headers CLF style | string list | | | %ms | accept date milliseconds | numeric | | | %pid | PID | numeric | | H | %r | http_request | string | @@ -12767,6 +12767,10 @@ follow the same representation, but are displayed after a space following the request headers block. These blocks are displayed just before the HTTP request in the logs. +As a special case, it is possible to specify an HTTP header capture in a TCP +frontend. The purpose is to enable logging of headers which will be parsed in +an HTTP backend if the request is then switched to this HTTP backend. + Example : # This instance chains to the outgoing proxy listen proxy-out diff --git a/src/cfgparse.c b/src/cfgparse.c index 06ea63ee3..00b75828d 100644 --- a/src/cfgparse.c +++ b/src/cfgparse.c @@ -6514,31 +6514,15 @@ out_uri_auth_compat: /* The small pools required for the capture lists */ if (curproxy->nb_req_cap) { - if (curproxy->mode == PR_MODE_HTTP) { - curproxy->req_cap_pool = create_pool("ptrcap", - curproxy->nb_req_cap * sizeof(char *), - MEM_F_SHARED); - } else { - Warning("config : 'capture request header' ignored for %s '%s' as it requires HTTP mode.\n", - proxy_type_str(curproxy), curproxy->id); - err_code |= ERR_WARN; - curproxy->to_log &= ~LW_REQHDR; - curproxy->nb_req_cap = 0; - } + curproxy->req_cap_pool = create_pool("ptrcap", + curproxy->nb_req_cap * sizeof(char *), + MEM_F_SHARED); } if (curproxy->nb_rsp_cap) { - if (curproxy->mode == PR_MODE_HTTP) { - curproxy->rsp_cap_pool = create_pool("ptrcap", - curproxy->nb_rsp_cap * sizeof(char *), - MEM_F_SHARED); - } else { - Warning("config : 'capture response header' ignored for %s '%s' as it requires HTTP mode.\n", - proxy_type_str(curproxy), curproxy->id); - err_code |= ERR_WARN; - curproxy->to_log &= ~LW_REQHDR; - curproxy->nb_rsp_cap = 0; - } + curproxy->rsp_cap_pool = create_pool("ptrcap", + curproxy->nb_rsp_cap * sizeof(char *), + MEM_F_SHARED); } /* first, we will invert the servers list order */ diff --git a/src/frontend.c b/src/frontend.c index f94c6ab2b..3f80774de 100644 --- a/src/frontend.c +++ b/src/frontend.c @@ -106,16 +106,11 @@ int frontend_accept(struct session *s) if (global.tune.client_rcvbuf) setsockopt(cfd, SOL_SOCKET, SO_RCVBUF, &global.tune.client_rcvbuf, sizeof(global.tune.client_rcvbuf)); - if (s->fe->mode == PR_MODE_HTTP) { - /* the captures are only used in HTTP frontends */ - if (unlikely(s->fe->nb_req_cap > 0 && - (s->txn.req.cap = pool_alloc2(s->fe->req_cap_pool)) == NULL)) - goto out_return; /* no memory */ + if (unlikely(s->fe->nb_req_cap > 0 && (s->txn.req.cap = pool_alloc2(s->fe->req_cap_pool)) == NULL)) + goto out_return; /* no memory */ - if (unlikely(s->fe->nb_rsp_cap > 0 && - (s->txn.rsp.cap = pool_alloc2(s->fe->rsp_cap_pool)) == NULL)) - goto out_free_reqcap; /* no memory */ - } + if (unlikely(s->fe->nb_rsp_cap > 0 && (s->txn.rsp.cap = pool_alloc2(s->fe->rsp_cap_pool)) == NULL)) + goto out_free_reqcap; /* no memory */ if (s->fe->http_needed) { /* we have to allocate header indexes only if we know diff --git a/src/log.c b/src/log.c index 392256f60..eb7ccb177 100644 --- a/src/log.c +++ b/src/log.c @@ -103,10 +103,10 @@ static const struct logformat_type logformat_keywords[] = { { "fi", LOG_FMT_FRONTENDIP, PR_MODE_TCP, LW_FRTIP, NULL }, /* frontend ip */ { "fp", LOG_FMT_FRONTENDPORT, PR_MODE_TCP, LW_FRTIP, NULL }, /* frontend port */ { "ft", LOG_FMT_FRONTEND_XPRT, PR_MODE_TCP, LW_INIT, NULL }, /* frontend with transport mode */ - { "hr", LOG_FMT_HDRREQUEST, PR_MODE_HTTP, LW_REQHDR, NULL }, /* header request */ - { "hrl", LOG_FMT_HDRREQUESTLIST, PR_MODE_HTTP, LW_REQHDR, NULL }, /* header request list */ - { "hs", LOG_FMT_HDRRESPONS, PR_MODE_HTTP, LW_RSPHDR, NULL }, /* header response */ - { "hsl", LOG_FMT_HDRRESPONSLIST, PR_MODE_HTTP, LW_RSPHDR, NULL }, /* header response list */ + { "hr", LOG_FMT_HDRREQUEST, PR_MODE_TCP, LW_REQHDR, NULL }, /* header request */ + { "hrl", LOG_FMT_HDRREQUESTLIST, PR_MODE_TCP, LW_REQHDR, NULL }, /* header request list */ + { "hs", LOG_FMT_HDRRESPONS, PR_MODE_TCP, LW_RSPHDR, NULL }, /* header response */ + { "hsl", LOG_FMT_HDRRESPONSLIST, PR_MODE_TCP, LW_RSPHDR, NULL }, /* header response list */ { "ms", LOG_FMT_MS, PR_MODE_TCP, LW_INIT, NULL }, /* accept date millisecond */ { "pid", LOG_FMT_PID, PR_MODE_TCP, LW_INIT, NULL }, /* log pid */ { "r", LOG_FMT_REQ, PR_MODE_HTTP, LW_REQ, NULL }, /* request */