From f9ef9b7e745ece58fead4dae343ef422c5206291 Mon Sep 17 00:00:00 2001
From: jurgenhaas <juergen@paragon-es.de>
Date: Fri, 1 Jun 2018 17:02:46 +0200
Subject: [PATCH] Improve redirect syntax if custom condition is provided

---
 templates/haproxy_cfg.jinja2 | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/templates/haproxy_cfg.jinja2 b/templates/haproxy_cfg.jinja2
index a1425f8..6ad09b6 100644
--- a/templates/haproxy_cfg.jinja2
+++ b/templates/haproxy_cfg.jinja2
@@ -105,7 +105,7 @@ frontend http_in
 {% for path in redirect.paths|default([]) %}
 {% if not path.deny|default(false) %}
 {% if path.regex is not defined or path.from is not defined %}
-  http-request redirect code 301 location {{ redirect.protocol|default('https') }}://{{redirect.to|default(from)}}{% if path.to is defined %}/{{path.to}}{% endif %}{% if path.append_path|default(false) %}%[capture.req.uri]{% endif %}{% if path.append_query is defined %}?{{ path.append_query }}{% endif %} if !letsencrypt_challenge { {{ (from == ".") | ternary('hdr_sub', 'hdr') }}(host) -i -n {{ from }}{% if path.from is defined %} } { {{path.exact|default(false)|ternary('path /','path_reg ^/')}}{{path.from}}{% endif %}{% if path.condition is defined %} {{path.condition}}{% endif %} }
+  http-request redirect code 301 location {{ redirect.protocol|default('https') }}://{{redirect.to|default(from)}}{% if path.to is defined %}/{{path.to}}{% endif %}{% if path.append_path|default(false) %}%[capture.req.uri]{% endif %}{% if path.append_query is defined %}?{{ path.append_query }}{% endif %} if !letsencrypt_challenge { {{ (from == ".") | ternary('hdr_sub', 'hdr') }}(host) -i -n {{ from }}{% if path.from is defined %} } { {{path.exact|default(false)|ternary('path /','path_reg ^/')}}{{path.from}}{% endif %}{% if path.condition is defined %} } { {{path.condition}}{% endif %} }
 {% endif %}
 {% endif %}
 {% endfor %}
@@ -235,7 +235,7 @@ frontend https_in_{{ cert.ip }}
 {% for path in redirect.paths|default([]) %}
 {% if not path.deny|default(false) %}
 {% if path.regex is not defined or path.from is not defined %}
-  http-request redirect code 301 location {{ redirect.protocol|default('https') }}://{{redirect.to|default(from)}}{% if path.to is defined %}/{{path.to}}{% endif %}{% if path.append_path|default(false) %}%[capture.req.uri]{% endif %}{% if path.append_query is defined %}?{{ path.append_query }}{% endif %} if { {{ (from == ".") | ternary('hdr_sub', 'hdr') }}(host) -i -n {{ from }}{% if path.from is defined %} } { {{path.exact|default(false)|ternary('path /','path_reg ^/')}}{{path.from}}{% endif %}{% if path.condition is defined %} {{path.condition}}{% endif %} }
+  http-request redirect code 301 location {{ redirect.protocol|default('https') }}://{{redirect.to|default(from)}}{% if path.to is defined %}/{{path.to}}{% endif %}{% if path.append_path|default(false) %}%[capture.req.uri]{% endif %}{% if path.append_query is defined %}?{{ path.append_query }}{% endif %} if { {{ (from == ".") | ternary('hdr_sub', 'hdr') }}(host) -i -n {{ from }}{% if path.from is defined %} } { {{path.exact|default(false)|ternary('path /','path_reg ^/')}}{{path.from}}{% endif %}{% if path.condition is defined %} } { {{path.condition}}{% endif %} }
 {% endif %}
 {% endif %}
 {% endfor %}
-- 
GitLab