From 84d16ffeaf63384197100610f08aa9b6e06c1944 Mon Sep 17 00:00:00 2001 From: Michael Weinrich Date: Wed, 6 Jul 2016 10:26:38 +0200 Subject: [PATCH] Add option to enable captures --- README.md | 8 ++++++++ templates/etc/haproxy/frontend.cfg.j2 | 4 ++++ templates/etc/haproxy/listen.cfg.j2 | 4 ++++ 3 files changed, 16 insertions(+) diff --git a/README.md b/README.md index 29ea1a88..a7426368 100644 --- a/README.md +++ b/README.md @@ -72,6 +72,10 @@ Set up (the latest version of) [HAProxy](http://www.haproxy.org/) in Ubuntu syst * `haproxy_listen.{n}.timeout`: [optional]: Timeout declarations * `haproxy_listen.{n}.timeout.type`: [required]: The type (e.g. `connect`, `client`, `server`) * `haproxy_listen.{n}.timeout.timeout`: [required]: The timeout (in in milliseconds by default, but can be in any other unit if the number is suffixed by the unit) (e.g. `5000`, `50000`) +* `haproxy_listen.{n}.capture`: [optional]: Capture fields from request or response +* `haproxy_listen.{n}.capture.type`: [required]: What to capture (`cookie`, `request header`, `response header`) +* `haproxy_listen.{n}.capture.name`: [required]: Name of the header or cookie to capture +* `haproxy_listen.{n}.capture.length`: [required]: Maximum number of characters to capture and report in the logs * `haproxy_listen.{n}.http_request`: [optional]: Access control for Layer 7 requests * `haproxy_listen.{n}.http_request.{n}.action`: [required]: The rules action (e.g. `add-header`) * `haproxy_listen.{n}.http_request.{n}.param`: [optional]: The complete line to be added (e.g. `X-Forwarded-Proto https`) @@ -109,6 +113,10 @@ Set up (the latest version of) [HAProxy](http://www.haproxy.org/) in Ubuntu syst * `haproxy_frontend.{n}.timeout`: [optional]: Timeout declarations * `haproxy_frontend.{n}.timeout.type`: [required]: The type (e.g. `client`) * `haproxy_frontend.{n}.timeout.timeout`: [required]: The timeout (in in milliseconds by default, but can be in any other unit if the number is suffixed by the unit) (e.g. `5000`, `50000`) +* `haproxy_frontend.{n}.capture`: [optional]: Capture fields from request or response +* `haproxy_frontend.{n}.capture.type`: [required]: What to capture (`cookie`, `request header`, `response header`) +* `haproxy_frontend.{n}.capture.name`: [required]: Name of the header or cookie to capture +* `haproxy_frontend.{n}.capture.length`: [required]: Maximum number of characters to capture and report in the logs * `haproxy_frontend.{n}.http_request`: [optional]: Access control for Layer 7 requests * `haproxy_frontend.{n}.http_request.{n}.action`: [required]: The rules action (e.g. `add-header`) * `haproxy_frontend.{n}.http_request.{n}.param`: [optional]: The complete line to be added (e.g. `X-Forwarded-Proto https`) diff --git a/templates/etc/haproxy/frontend.cfg.j2 b/templates/etc/haproxy/frontend.cfg.j2 index 9d0dfc7a..31bca2a9 100644 --- a/templates/etc/haproxy/frontend.cfg.j2 +++ b/templates/etc/haproxy/frontend.cfg.j2 @@ -31,6 +31,10 @@ frontend {{ frontend.name }} timeout {{ timeout.type }} {{ timeout.timeout }} {% endfor %} +{% for capture in frontend.capture | default([]) %} + capture {{ capture.type }} {{ capture.name }} len {{ capture.length }} +{% endfor %} + {% for http_request in frontend.http_request | default([]) %} http-request {{ http_request.action }}{% if http_request.param is defined %} {{ http_request.param }}{% endif %}{% if http_request.cond is defined %} {{ http_request.cond }}{% endif %} diff --git a/templates/etc/haproxy/listen.cfg.j2 b/templates/etc/haproxy/listen.cfg.j2 index 8650725f..2e3aa8c0 100644 --- a/templates/etc/haproxy/listen.cfg.j2 +++ b/templates/etc/haproxy/listen.cfg.j2 @@ -39,6 +39,10 @@ listen {{ listen.name }} timeout {{ timeout.type }} {{ timeout.timeout }} {% endfor %} +{% for capture in listen.capture | default([]) %} + capture {{ capture.type }} {{ capture.name }} len {{ capture.length }} +{% endfor %} + {% if listen.stats is defined %} {% if listen.stats.enable is defined and listen.stats.enable | bool == true %} stats enable