Skip to content
Snippets Groups Projects
Commit e82a5fc9 authored by jurgenhaas's avatar jurgenhaas
Browse files

#6 Implement support for redirect maps based on domain or path

parent 5e708914
No related branches found
No related tags found
No related merge requests found
......@@ -8,6 +8,9 @@ proxy_timeout_server: '45s'
proxy_redirect_aliase: false
proxy_maxconn: 100
proxy_varnish_maxconn: 1000
proxy_redirect_maps:
domain: {}
path: {}
proxy_blacklist:
ip:
- '146.185.176.158'
......
......@@ -105,6 +105,18 @@
when: haproxy_private is defined and haproxy_private.domain is defined
notify: "Check HAProxy Config"
- name: "Update redirect map files"
template:
src='redirect.map.jinja2'
dest='/etc/haproxy/redirect.{{ item }}.map'
owner='root'
group='root'
mode='644'
with_items:
- 'domain'
- 'path'
notify: "Check HAProxy Config"
- name: "Create config file"
template:
src='haproxy_cfg.jinja2'
......
......@@ -60,6 +60,8 @@ userlist notprivate
frontend http_in
bind *:80
http-request del-header Proxy
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 %[capture.req.uri,map(/etc/haproxy/redirect.path.map)] if { capture.req.uri,map(/etc/haproxy/redirect.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
......@@ -187,6 +189,8 @@ 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 %[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 %[capture.req.uri,map(/etc/haproxy/redirect.path.map)] if { capture.req.uri,map(/etc/haproxy/redirect.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
......
{% for key in proxy_redirect_maps[item] %}
{{ key }} {{ proxy_redirect_maps[item][key] }}
{% endfor %}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment