diff --git a/templates/haproxy_cfg b/templates/haproxy_cfg index ba761a43d2f7c347727ac02a3f3d39cba8bc9527..cb582444013b46c10b06144719f21ce86f54e592 100644 --- a/templates/haproxy_cfg +++ b/templates/haproxy_cfg @@ -66,7 +66,11 @@ frontend http_in {% for redirect in hostvars[host].proxy_redirect|default([]) %} {% 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 %} } +{% else %} 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 %} } +{% endif %} {% endfor %} redirect prefix {{ redirect.protocol|default('https') }}://{{redirect.to}} code 301 if { hdr(host) -i -n {{from}} } {% endfor %} @@ -129,7 +133,11 @@ frontend https_in_{{ cert.ip }} {% for redirect in hostvars[host].proxy_redirect|default([]) %} {% 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 %} } +{% else %} 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 %} } +{% endif %} {% endfor %} redirect prefix {{ redirect.protocol|default('https') }}://{{redirect.to}} code 301 if { hdr(host) -i -n {{from}} } {% endfor %}