Allow setting http-request options and fix acl syntax
diff --git a/README.rst b/README.rst
index 265ec7c..d25f804 100644
--- a/README.rst
+++ b/README.rst
@@ -24,7 +24,6 @@
user: fsdfdsfds
password: dsfdsf
-
Simple stats listener
.. code-block:: yaml
@@ -208,6 +207,41 @@
port: 5000
params: check
+Custom more complex listener (for Artifactory and subdomains for docker
+registries)
+
+.. code-block:: yaml
+
+ haproxy:
+ proxy:
+ listen:
+ artifactory:
+ mode: http
+ options:
+ - forwardfor
+ - forwardfor header X-Real-IP
+ - httpchk
+ - httpclose
+ - httplog
+ acl:
+ is_docker: "path_reg ^/v[12][/.]*"
+ http_request:
+ - action: "set-path /artifactory/api/docker/%[req.hdr(host),lower,field(1,'.')]%[path]"
+ condition: "if is_docker"
+ balance: source
+ binds:
+ - address: ${_param:cluster_vip_address}
+ port: 8082
+ servers:
+ - name: ${_param:cluster_node01_name}
+ host: ${_param:cluster_node01_address}
+ port: 8082
+ params: check
+ - name: ${_param:cluster_node02_name}
+ host: ${_param:cluster_node02_address}
+ port: 8082
+ params: backup check
+
Read more
=========
diff --git a/haproxy/files/haproxy.cfg b/haproxy/files/haproxy.cfg
index 19178f9..65da9c6 100644
--- a/haproxy/files/haproxy.cfg
+++ b/haproxy/files/haproxy.cfg
@@ -134,10 +134,13 @@
{%- else %}
{# no type specified #}
mode {{ listen.mode|default('tcp') }}
- {%- for acl in listen.get('acl', []) %}
- acl {{ acl }}
- {%- endfor %}
balance {{ listen.balance|default('roundrobin') }}
+ {%- for aclname, acl in listen.get('acl', {}).iteritems() %}
+ acl {{ aclname }} {{ acl }}
+ {%- endfor %}
+ {%- for http_request in listen.get('http_request', []) %}
+ http-request {{ http_request.action }}{% if http_request.condition is defined %} {{ http_request.condition }}{% endif %}
+ {%- endfor %}
{%- for option in listen.get('options', []) %}
option {{ option }}
{%- endfor %}