From 8b2ee5198551ef4e4dc958947ecc372afe408340 Mon Sep 17 00:00:00 2001 From: jurgenhaas <juergen@paragon-es.de> Date: Mon, 13 Mar 2017 12:19:51 +0100 Subject: [PATCH] Redirect prefix only if no paths defined and implement regex support for the from keyword --- templates/haproxy_cfg.jinja2 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/templates/haproxy_cfg.jinja2 b/templates/haproxy_cfg.jinja2 index 12c16e7..bdfb0fc 100644 --- a/templates/haproxy_cfg.jinja2 +++ b/templates/haproxy_cfg.jinja2 @@ -84,11 +84,11 @@ 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 %} - redirect location {{ redirect.protocol|default('https') }}://{{redirect.to}}/{{path.to|default('')}}{% if path.append_path|default(false) %}%[path]{% endif %}{% if path.append_query is defined %}?{{ path.append_query }}{% endif %} code 301 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 %} } + redirect location {{ redirect.protocol|default('https') }}://{{redirect.to}}/{{path.to|default('')}}{% if path.append_path|default(false) %}%[path]{% endif %}{% if path.append_query is defined %}?{{ path.append_query }}{% endif %} code 301 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 %} } {% endif %} {% endif %} {% endfor %} -{% if (from != redirect.to or redirect.protocol|default('https') == 'https') and from != "." %} +{% if (from != redirect.to or redirect.protocol|default('https') == 'https') and redirect.paths is not defined %} redirect prefix {{ redirect.protocol|default('https') }}://{{redirect.to}} code 301 if { hdr(host) -i -n {{ from }} } {% endif %} {% endfor %} @@ -194,11 +194,11 @@ 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 %} - redirect location {{ redirect.protocol|default('https') }}://{{redirect.to}}/{{path.to|default('')}}{% if path.append_path|default(false) %}%[path]{% endif %}{% if path.append_query is defined %}?{{ path.append_query }}{% endif %} code 301 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 %} } + redirect location {{ redirect.protocol|default('https') }}://{{redirect.to}}/{{path.to|default('')}}{% if path.append_path|default(false) %}%[path]{% endif %}{% if path.append_query is defined %}?{{ path.append_query }}{% endif %} code 301 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 %} } {% endif %} {% endif %} {% endfor %} -{% if (from != redirect.to or redirect.protocol|default('https') != 'https') and from != "." %} +{% if (from != redirect.to or redirect.protocol|default('https') != 'https') and redirect.paths is not defined %} redirect prefix {{ redirect.protocol|default('https') }}://{{redirect.to}} code 301 if { hdr(host) -i -n {{ from }} } {% endif %} {% endfor %} -- GitLab