diff --git a/.gitignore b/.gitignore index f74c83aa..ec755a5e 100644 --- a/.gitignore +++ b/.gitignore @@ -28,3 +28,4 @@ ansible.cfg # Other files # ############### !empty +*.sw[po] diff --git a/README.md b/README.md index b5da0ed7..e154ba53 100644 --- a/README.md +++ b/README.md @@ -137,6 +137,10 @@ Set up (the latest version of) [HAProxy](http://www.haproxy.org/) in Ubuntu syst * `haproxy_listen.{n}.rsprep`: [optional]: Response regexp edit definition * `haproxy_listen.{n}.rsprep.{n}.string`: [required]: Regexp definition to be used on response * `haproxy_listen.{n}.rsprep.{n}.cond`: [optional]: A condition to apply this rule +* `haproxy_listen.{n}.rspirep`: [optional]: Response regexp edit definition +* `haproxy_listen.{n}.rspirep.{n}.search`: [required]: The regular expression applied to HTTP headers and to the response line +* `haproxy_listen.{n}.rspirep.{n}.string`: [required]: The complete line to be added +* `haproxy_listen.{n}.rspirep.{n}.cond`: [optional]: Matching condition built from ACLs * `haproxy_listen.{n}.errorfile`: [optional]: Errorfile declarations * `haproxy_listen.{n}.errorfile.{n}.code`: [required]: The HTTP status code. Currently, HAProxy is capable of generating codes 200, 400, 403, 408, 500, 502, 503, and 504 (e.g. `400`) * `haproxy_listen.{n}.errorfile.{n}.file`: [required]: A file containing the full HTTP response (e.g `/etc/haproxy/errors/400.http`) @@ -185,6 +189,10 @@ Set up (the latest version of) [HAProxy](http://www.haproxy.org/) in Ubuntu syst * `haproxy_frontend.{n}.rsprep`: [optional]: Response regexp edit definition * `haproxy_frontend.{n}.rsprep.{n}.string`: [required]: Regexp definition to be used on response * `haproxy_frontend.{n}.rsprep.{n}.cond`: [optional]: A condition to apply this rule +* `haproxy_frontend.{n}.rspirep`: [optional]: Response regexp edit definition +* `haproxy_frontend.{n}.rspirep.{n}.search`: [required]: The regular expression applied to HTTP headers and to the response line +* `haproxy_frontend.{n}.rspirep.{n}.string`: [required]: The complete line to be added +* `haproxy_frontend.{n}.rspirep.{n}.cond`: [optional]: Matching condition built from ACLs * `haproxy_frontend.{n}.compression`: [optional]: Compression declarations * `haproxy_frontend.{n}.compression.{n}.name`: [required]: The compression name (e.g. `algo`, `type`, `offload`) * `haproxy_frontend.{n}.compression.{n}.value`: [required]: The compression value, (e.g. if name = algo : one of this values `identity`, `gzip`, `deflate`, `raw-deflate` / if name = type : list of mime type separated by space for example `text/html text/plain text/css` / if name = `offload` value is empty) @@ -213,6 +221,10 @@ Set up (the latest version of) [HAProxy](http://www.haproxy.org/) in Ubuntu syst * `haproxy_backend.{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_backend.{n}.acl`: [optional]: Create an ACL check which can be later used in evaluations/conditionals * `haproxy_backend.{n}.acl.{n}.string`: [required]: ACL entry to be used in conditional check later +* `haproxy_backend.{n}.rspirep`: [optional]: Response regexp edit definition +* `haproxy_backend.{n}.rspirep.{n}.search`: [required]: The regular expression applied to HTTP headers and to the response line +* `haproxy_backend.{n}.rspirep.{n}.string`: [required]: The complete line to be added +* `haproxy_backend.{n}.rspirep.{n}.cond`: [optional]: Matching condition built from ACLs * `haproxy_backend.{n}.cookie`: [optional]: Enable cookie-based persistence in a backend (e.g. `JSESSIONID prefix nocache`) * `haproxy_backend.{n}.http_request`: [optional]: Access control for Layer 7 requests * `haproxy_backend.{n}.http_request.{n}.action`: [required]: The rules action (e.g. `add-header`) diff --git a/templates/etc/haproxy/backend.cfg.j2 b/templates/etc/haproxy/backend.cfg.j2 index 29aea9fc..e3e9cd24 100644 --- a/templates/etc/haproxy/backend.cfg.j2 +++ b/templates/etc/haproxy/backend.cfg.j2 @@ -57,6 +57,11 @@ backend {{ backend.name }} acl {{ acl.string }} {% endfor %} +{% for rspirep in backend.rspirep | default([]) %} + rspirep {{ rspirep.search }} {{ rspirep.string }}{% if rspirep.cond is defined %} {{ rspirep.cond }}{% endif %} + +{% endfor %} + {% if backend.stats is defined %} {% if backend.stats.enable is defined and backend.stats.enable | bool == true %} stats enable diff --git a/templates/etc/haproxy/frontend.cfg.j2 b/templates/etc/haproxy/frontend.cfg.j2 index b65c158c..48adce3b 100644 --- a/templates/etc/haproxy/frontend.cfg.j2 +++ b/templates/etc/haproxy/frontend.cfg.j2 @@ -76,6 +76,11 @@ frontend {{ frontend.name }} {% endfor %} +{% for rspirep in frontend.rspirep | default([]) %} + rspirep {{ rspirep.search }} {{ rspirep.string }}{% if rspirep.cond is defined %} {{ rspirep.cond }}{% endif %} + +{% endfor %} + {% for redirect in frontend.redirect | default([]) %} redirect {{ redirect.string }}{% if redirect.cond is defined %} {{ redirect.cond }}{% endif %} diff --git a/templates/etc/haproxy/listen.cfg.j2 b/templates/etc/haproxy/listen.cfg.j2 index efe61cbe..62235515 100644 --- a/templates/etc/haproxy/listen.cfg.j2 +++ b/templates/etc/haproxy/listen.cfg.j2 @@ -104,6 +104,11 @@ listen {{ listen.name }} {% endfor %} +{% for rspirep in listen.rspirep | default([]) %} + rspirep {{ rspirep.search }} {{ rspirep.string }}{% if rspirep.cond is defined %} {{ rspirep.cond }}{% endif %} + +{% endfor %} + {% for redirect in listen.redirect | default([]) %} redirect {{ redirect.string }}{% if redirect.cond is defined %} {{ redirect.cond }}{% endif %}