From 9aae7acc67ba05b7f22d18695d2f27d06e9c04f2 Mon Sep 17 00:00:00 2001 From: jurgenhaas <juergen@paragon-es.de> Date: Mon, 10 Oct 2016 11:18:47 +0200 Subject: [PATCH] ansible-inventories/arocom#177 Allow redirects for exact paths --- templates/haproxy_cfg | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/templates/haproxy_cfg b/templates/haproxy_cfg index 747e2b2..1974db7 100644 --- a/templates/haproxy_cfg +++ b/templates/haproxy_cfg @@ -67,7 +67,7 @@ frontend http_in {% for from in redirect.from %} {% for path in redirect.paths|default([]) %} {% if path.deny|default(false) %} - http-request deny if { hdr(host) -i -n {{from}}{% if path.from is defined %} } { path_beg /{{path.from}}{% endif %} } + http-request deny if { hdr(host) -i -n {{from}}{% if path.from is defined %} } { {{path.exact|default(false)|ternary('path','path_beg')}} /{{path.from}}{% endif %} } {% endif %} {% endfor %} {% endfor %} @@ -78,10 +78,12 @@ frontend http_in {% for from in redirect.from %} {% for path in redirect.paths|default([]) %} {% if not path.deny|default(false) %} - redirect location {{ redirect.protocol|default('https') }}://{{redirect.to}}/{{path.to|default('')}} code 301 if { hdr(host) -i -n {{from}}{% if path.from is defined %} } { path_beg /{{path.from}}{% endif %} } + redirect location {{ redirect.protocol|default('https') }}://{{redirect.to}}/{{path.to|default('')}} code 301 if { hdr(host) -i -n {{from}}{% if path.from is defined %} } { {{path.exact|default(false)|ternary('path','path_beg')}} /{{path.from}}{% endif %} } {% endif %} {% endfor %} +{% if from != redirect.to or redirect.protocol|default('https') == 'https' %} redirect prefix {{ redirect.protocol|default('https') }}://{{redirect.to}} code 301 if { hdr(host) -i -n {{from}} } +{% endif %} {% endfor %} {% endfor %} {% if proxy_redirect_aliase %} @@ -143,7 +145,7 @@ frontend https_in_{{ cert.ip }} {% for from in redirect.from %} {% for path in redirect.paths|default([]) %} {% if path.deny|default(false) %} - http-request deny if { hdr(host) -i -n {{from}}{% if path.from is defined %} } { path_beg /{{path.from}}{% endif %} } + http-request deny if { hdr(host) -i -n {{from}}{% if path.from is defined %} } { {{path.exact|default(false)|ternary('path','path_beg')}} /{{path.from}}{% endif %} } {% endif %} {% endfor %} {% endfor %} @@ -154,10 +156,12 @@ frontend https_in_{{ cert.ip }} {% for from in redirect.from %} {% for path in redirect.paths|default([]) %} {% if not path.deny|default(false) %} - redirect location {{ redirect.protocol|default('https') }}://{{redirect.to}}/{{path.to|default('')}} code 301 if { hdr(host) -i -n {{from}}{% if path.from is defined %} } { path_beg /{{path.from}}{% endif %} } + redirect location {{ redirect.protocol|default('https') }}://{{redirect.to}}/{{path.to|default('')}} code 301 if { hdr(host) -i -n {{from}}{% if path.from is defined %} } { {{path.exact|default(false)|ternary('path','path_beg')}} /{{path.from}}{% endif %} } {% endif %} {% endfor %} +{% if from != redirect.to or redirect.protocol|default('https') != 'https' %} redirect prefix {{ redirect.protocol|default('https') }}://{{redirect.to}} code 301 if { hdr(host) -i -n {{from}} } +{% endif %} {% endfor %} {% endfor %} {% if proxy_redirect_aliase %} -- GitLab