diff --git a/README.md b/README.md index aedaddc1..7f6e1ae2 100644 --- a/README.md +++ b/README.md @@ -113,7 +113,8 @@ Set up (the latest version of) [HAProxy](http://www.haproxy.org/) in Ubuntu syst * `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}.filter`: [optional]: Dictionary of content filters to apply to this section -* `haproxy_listen.{n}.filter.{name}`: [required]: One or more filter `name: param` entries to apply +* `haproxy_listen.{n}.filter.{n}.name`: [required]: The filter to apply +* `haproxy_listen.{n}.filter.{n}.params`: [optional]: Parameters for the filter * `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`) diff --git a/templates/etc/haproxy/backend.cfg.j2 b/templates/etc/haproxy/backend.cfg.j2 index 1b91cb60..2bef5576 100644 --- a/templates/etc/haproxy/backend.cfg.j2 +++ b/templates/etc/haproxy/backend.cfg.j2 @@ -23,11 +23,9 @@ backend {{ backend.name }} {% if backend.cookie is defined %} cookie {{ backend.cookie }} {% endif %} -{% if backend.filter is defined %} -{% for name, value in backend.filter.items() %} - filter {{ name }} {{ value }} +{% for filter in backend.filter | default([]) %} + filter {{ filter.name }}{{ filter.params is defined | ternary([''] + [filter.params], []) | join(' ') }} {% endfor %} -{% endif %} {% for acl in backend.acl | default([]) %} acl {{ acl.string }} {% endfor %} diff --git a/templates/etc/haproxy/frontend.cfg.j2 b/templates/etc/haproxy/frontend.cfg.j2 index 15afc69c..fbfe87ed 100644 --- a/templates/etc/haproxy/frontend.cfg.j2 +++ b/templates/etc/haproxy/frontend.cfg.j2 @@ -32,11 +32,9 @@ frontend {{ frontend.name }} {% for timeout in frontend.timeout | default([]) %} timeout {{ timeout.type }} {{ timeout.timeout }} {% endfor %} -{% if frontend.filter is defined %} -{% for name, value in frontend.filter.items() %} - filter {{ name }} {{ value }} +{% for filter in frontend.filter | default([]) %} + filter {{ filter.name }}{{ filter.params is defined | ternary([''] + [filter.params], []) | join(' ') }} {% endfor %} -{% endif %} {% for acl in frontend.acl | default([]) %} acl {{ acl.string }} {% endfor %} diff --git a/templates/etc/haproxy/listen.cfg.j2 b/templates/etc/haproxy/listen.cfg.j2 index 8cfa9332..54f1c45d 100644 --- a/templates/etc/haproxy/listen.cfg.j2 +++ b/templates/etc/haproxy/listen.cfg.j2 @@ -42,11 +42,9 @@ listen {{ listen.name }} {% for timeout in listen.timeout | default([]) %} timeout {{ timeout.type }} {{ timeout.timeout }} {% endfor %} -{% if listen.filter is defined %} -{% for name, value in listen.filter.items() %} - filter {{ name }} {{ value }} +{% for filter in listen.filter | default([]) %} + filter {{ filter.name }}{{ filter.params is defined | ternary([''] + [filter.params], []) | join(' ') }} {% endfor %} -{% endif %} {% for acl in listen.acl | default([]) %} acl {{ acl.string }} {% endfor %}