From 7017dc7120d1015435ebd37f1770e60454d19c2e Mon Sep 17 00:00:00 2001 From: jurgenhaas <juergen@paragon-es.de> Date: Tue, 26 Jun 2018 10:47:49 +0200 Subject: [PATCH] Implement support for redirect maps with domain and path as the key --- defaults/main.yml | 1 + tasks/configure.yml | 1 + templates/haproxy_cfg.jinja2 | 2 ++ 3 files changed, 4 insertions(+) diff --git a/defaults/main.yml b/defaults/main.yml index bb72b54..c396397 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -10,6 +10,7 @@ proxy_maxconn: 100 proxy_varnish_maxconn: 1000 proxy_redirect_maps: domain: {} + domain-and-path: {} domain-append-path: {} path: {} proxy_blacklist: diff --git a/tasks/configure.yml b/tasks/configure.yml index e85f876..09b168f 100644 --- a/tasks/configure.yml +++ b/tasks/configure.yml @@ -114,6 +114,7 @@ mode='644' with_items: - 'domain' + - 'domain-and-path' - 'domain-append-path' - 'path' notify: "Check HAProxy Config" diff --git a/templates/haproxy_cfg.jinja2 b/templates/haproxy_cfg.jinja2 index 11fef51..6c73623 100644 --- a/templates/haproxy_cfg.jinja2 +++ b/templates/haproxy_cfg.jinja2 @@ -71,6 +71,7 @@ frontend http_in {% endfor %} http-request set-header x-routing-host undefined acl letsencrypt_challenge path_beg /.well-known/acme-challenge/ + http-request redirect code 301 location %[base,map(/etc/haproxy/redirect.domain-and-path.map)] if !letsencrypt_challenge { base,map(/etc/haproxy/redirect.domain-and-path.map) -m found } 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 } @@ -191,6 +192,7 @@ frontend http_in frontend https_in_{{ cert.ip }} bind {{ cert.ip }}:443 ssl crt /etc/haproxy/certs/{{ cert.file }} no-sslv3 http-request del-header Proxy + http-request redirect code 301 location %[base,map(/etc/haproxy/redirect.domain-and-path.map)] if { base,map(/etc/haproxy/redirect.domain-and-path.map) -m found } 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 } -- GitLab