From 19631d00304c8a63dc5e716a2f898dbe7ce26860 Mon Sep 17 00:00:00 2001
From: jurgenhaas <juergen@paragon-es.de>
Date: Mon, 28 May 2018 11:04:43 +0200
Subject: [PATCH] Implement redirect map by domain with appended path on
 destination

---
 tasks/configure.yml          | 1 +
 templates/haproxy_cfg.jinja2 | 2 ++
 2 files changed, 3 insertions(+)

diff --git a/tasks/configure.yml b/tasks/configure.yml
index 8e783df..e85f876 100644
--- a/tasks/configure.yml
+++ b/tasks/configure.yml
@@ -114,6 +114,7 @@
     mode='644'
   with_items:
     - 'domain'
+    - 'domain-append-path'
     - 'path'
   notify: "Check HAProxy Config"
 
diff --git a/templates/haproxy_cfg.jinja2 b/templates/haproxy_cfg.jinja2
index 6634537..72671e2 100644
--- a/templates/haproxy_cfg.jinja2
+++ b/templates/haproxy_cfg.jinja2
@@ -73,6 +73,7 @@ frontend http_in
   acl letsencrypt_challenge path_beg /.well-known/acme-challenge/
   http-request redirect code 301 location %[capture.req.uri,map(/etc/haproxy/redirect.path.map)] if !letsencrypt_challenge { capture.req.uri,map(/etc/haproxy/redirect.path.map) -m found }
   http-request redirect code 301 location %[hdr(host),map(/etc/haproxy/redirect.domain.map)] if !letsencrypt_challenge { hdr(host),map(/etc/haproxy/redirect.domain.map) -m found }
+  http-request redirect code 301 location %[hdr(host),map(/etc/haproxy/redirect.domain-append-path.map)]%[capture.req.uri] if !letsencrypt_challenge { hdr(host),map(/etc/haproxy/redirect.domain-append-path.map) -m found }
 {% if haproxy_private is defined %}
 {% if haproxy_private.domain is defined %}
   acl privatedomain hdr(host) -i -n -f /etc/haproxy/privatelist.domain
@@ -192,6 +193,7 @@ frontend https_in_{{ cert.ip }}
   http-request del-header Proxy
   http-request redirect code 301 location %[capture.req.uri,map(/etc/haproxy/redirect.path.map)] if { capture.req.uri,map(/etc/haproxy/redirect.path.map) -m found }
   http-request redirect code 301 location %[hdr(host),map(/etc/haproxy/redirect.domain.map)] if { hdr(host),map(/etc/haproxy/redirect.domain.map) -m found }
+  http-request redirect code 301 location %[hdr(host),map(/etc/haproxy/redirect.domain-append-path.map)]%[capture.req.uri] if { hdr(host),map(/etc/haproxy/redirect.domain-append-path.map) -m found }
 {% if haproxy_private is defined %}
 {% if haproxy_private.domain is defined %}
   acl privatedomain hdr(host) -i -n -f /etc/haproxy/privatelist.domain
-- 
GitLab