From 859b835d4f98e8c56c2d737c461b57eae21cbd56 Mon Sep 17 00:00:00 2001
From: jurgenhaas <juergen@paragon-es.de>
Date: Tue, 14 Mar 2017 15:46:38 +0100
Subject: [PATCH] Allow prefix together with regex and use regex for non exact
 from queries

---
 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 82614a5..c141b99 100644
--- a/templates/haproxy_cfg.jinja2
+++ b/templates/haproxy_cfg.jinja2
@@ -71,7 +71,7 @@ frontend http_in
   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_beg')}} /{{path.from}}{% endif %} }
 {% else %}
 {% if path.regex is defined and path.from is defined %}
-  http-request redirect code 301 location %[capture.req.uri,regsub({{path.regex}},)] if { {{ (from == ".") | ternary('hdr_sub', 'hdr') }}(host) -i -n {{ from }} } { path_beg /{{path.from}} }
+  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}} }
 {% endif %}
 {% endif %}
 {% endfor %}
@@ -181,7 +181,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_beg')}} /{{path.from}}{% endif %} }
 {% else %}
 {% if path.regex is defined and path.from is defined %}
-  http-request redirect code 301 location %[capture.req.uri,regsub({{path.regex}},)] if { {{ (from == ".") | ternary('hdr_sub', 'hdr') }}(host) -i -n {{ from }} } { path_beg /{{path.from}} }
+  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}} }
 {% endif %}
 {% endif %}
 {% endfor %}
-- 
GitLab