From 750cf35eb83e270c85194af91c7716804742ce2c Mon Sep 17 00:00:00 2001
From: jurgenhaas <juergen@paragon-es.de>
Date: Thu, 16 Jul 2020 10:28:04 +0200
Subject: [PATCH] ansible-inventories/arocom#2905 Add support for to-domain
 together with regex

---
 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 b635792..0e8b955 100644
--- a/templates/haproxy_cfg.jinja2
+++ b/templates/haproxy_cfg.jinja2
@@ -90,7 +90,7 @@ frontend http_in
   http-request deny 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 %} }
 {% else %}
 {% if path.regex is defined and path.from is defined %}
-  http-request redirect code 301 location {{ path.to|default('') }}%[capture.req.uri,regsub({{path.regex}},)] if !letsencrypt_challenge { {{ (from == ".") | ternary('hdr_sub', 'hdr') }}(host) -i -n {{ from }} } { {{path.exact|default(false)|ternary('path /','path_reg ^/')}}{{path.from}} }
+  http-request redirect code 301 location {% if path.usedomain|default(false) %}{{ redirect.protocol|default('https') }}://{{redirect.to|default(from)}}{% endif %}{{ path.to|default('') }}%[capture.req.uri,regsub({{path.regex}},)] if !letsencrypt_challenge { {{ (from == ".") | ternary('hdr_sub', 'hdr') }}(host) -i -n {{ from }} } { {{path.exact|default(false)|ternary('path /','path_reg ^/')}}{{path.from}} }
 {% endif %}
 {% endif %}
 {% endfor %}
@@ -235,7 +235,7 @@ frontend https_in_{{ cert.ip }}
   http-request deny 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 %} }
 {% else %}
 {% if path.regex is defined and path.from is defined %}
-  http-request redirect code 301 location {{ path.to|default('') }}%[capture.req.uri,regsub({{path.regex}},)] if { {{ (from == ".") | ternary('hdr_sub', 'hdr') }}(host) -i -n {{ from }} } { {{path.exact|default(false)|ternary('path /','path_reg ^/')}}{{path.from}} }
+  http-request redirect code 301 location {% if path.usedomain|default(false) %}{{ redirect.protocol|default('https') }}://{{redirect.to|default(from)}}{% endif %}{{ path.to|default('') }}%[capture.req.uri,regsub({{path.regex}},)] if { {{ (from == ".") | ternary('hdr_sub', 'hdr') }}(host) -i -n {{ from }} } { {{path.exact|default(false)|ternary('path /','path_reg ^/')}}{{path.from}} }
 {% endif %}
 {% endif %}
 {% endfor %}
-- 
GitLab