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

ansible-inventories/alphabet#58 Implement routing with paths instead of domains

parent 8daa2739
No related branches found
No related tags found
No related merge requests found
......@@ -29,6 +29,16 @@
with_items: '{{ groups.webserver }}'
notify: 'Proxy | Restart HAProxy'
- name: "Proxy | Create host path lists"
file:
dest='/etc/haproxy/{{item}}.path.list'
owner='root'
group='root'
mode='644'
state='touch'
with_items: '{{ groups.webserver }}'
changed_when: false
- name: "Proxy | Create use bigpipe host lists"
template:
src='use_bigpipe_list'
......
......@@ -62,6 +62,7 @@ frontend http_in
{% for rule in proxy_blacklist.other|default([]) %}
http-request deny if { {{ rule }} }
{% endfor %}
http-request set-header x-routing-host undefined
{% for host in groups['all'] %}
{% for redirect in hostvars[host].proxy_redirect|default([]) %}
{% for from in redirect.from %}
......@@ -104,6 +105,21 @@ frontend http_in
{% endfor %}
{% endif %}
{% endfor %}
{% for host in groups['webserver'] %}
{% if hostvars[host].routing is defined %}
http-request set-header x-routing-host {{ host }} if { hdr(x-routing-host) undefined } { hdr(host) -i -n {{ hostvars[host].routing.domain }} } { path -i -n -f /etc/haproxy/{{ host }}.path.list }
{% endif %}
{% endfor %}
{% for host in groups['webserver'] %}
{% if hostvars[host].routing is defined %}
{% for path in hostvars[host].routing.paths|default([]) %}
http-request set-header x-routing-host {{ host }} if { hdr(x-routing-host) undefined } { hdr(host) -i -n {{ hostvars[host].routing.domain }} } { path_beg {{ path }} }
{% endfor %}
{% endif %}
{% endfor %}
{% if routing is defined and routing.default is defined %}
http-request set-header x-routing-host {{ routing.default }} if { hdr(x-routing-host) undefined } { hdr(host) -i -n {{ routing.domain }} }
{% endif %}
{% if kibana_users is defined %}
acl kibana_present hdr(host) -i -n '{{ kibana_domain|default(inventory_hostname) }}'
use_backend backend_redirect_ssl if kibana_present
......@@ -123,6 +139,10 @@ frontend http_in
acl static_content path_end .jpg .jpeg .gif .png .ico .swf .css .js .htm .html
use_backend backend_varnish if static_content !domain_ignores_varnish
{% endif %}
{% for host in groups['webserver'] %}
use_backend backend_{{ host }}_bigpipe if domain_uses_bigpipe { hdr(x-routing-host) {{ host }} }
use_backend backend_{{ host }} if { hdr(x-routing-host) {{ host }} }
{% endfor %}
{% for host in groups['webserver'] %}
acl domain_in_{{host}} hdr(host) -i -n -f /etc/haproxy/{{host}}.list
use_backend backend_{{host}}_bigpipe if domain_uses_bigpipe domain_in_{{host}}
......@@ -150,6 +170,7 @@ frontend https_in_{{ cert.ip }}
{% for rule in proxy_blacklist.other|default([]) %}
http-request deny if { {{ rule }} }
{% endfor %}
http-request set-header x-routing-host undefined
{% for host in groups['all'] %}
{% for redirect in hostvars[host].proxy_redirect|default([]) %}
{% for from in redirect.from %}
......@@ -192,6 +213,21 @@ frontend https_in_{{ cert.ip }}
{% endfor %}
{% endif %}
{% endfor %}
{% for host in groups['webserver'] %}
{% if hostvars[host].routing is defined %}
http-request set-header x-routing-host {{ host }} if { hdr(x-routing-host) undefined } { hdr(host) -i -n {{ hostvars[host].routing.domain }} } { path -i -n -f /etc/haproxy/{{ host }}.path.list }
{% endif %}
{% endfor %}
{% for host in groups['webserver'] %}
{% if hostvars[host].routing is defined %}
{% for path in hostvars[host].routing.paths|default([]) %}
http-request set-header x-routing-host {{ host }} if { hdr(x-routing-host) undefined } { hdr(host) -i -n {{ hostvars[host].routing.domain }} } { path_beg {{ path }} }
{% endfor %}
{% endif %}
{% endfor %}
{% if routing is defined and routing.default is defined %}
http-request set-header x-routing-host {{ routing.default }} if { hdr(x-routing-host) undefined } { hdr(host) -i -n {{ routing.domain }} }
{% endif %}
{% if kibana_users is defined %}
acl kibana_present hdr(host) -i -n '{{ kibana_domain|default(inventory_hostname) }}'
use_backend backend_kibana if kibana_present
......@@ -211,6 +247,10 @@ frontend https_in_{{ cert.ip }}
acl static_content path_end .jpg .jpeg .gif .png .ico .swf .css .js .htm .html
use_backend backend_varnish if static_content !domain_ignores_varnish
{% endif %}
{% for host in groups['webserver'] %}
use_backend backend_{{ host }}_https_bigpipe if domain_uses_bigpipe { hdr(x-routing-host) {{ host }} }
use_backend backend_{{ host }}_https if { hdr(x-routing-host) {{ host }} }
{% endfor %}
{% for host in groups['webserver'] %}
acl ssl_domain_in_{{host}} hdr(host) -i -n -f /etc/haproxy/{{host}}.ssl.list
use_backend backend_{{host}}_https_bigpipe if domain_uses_bigpipe ssl_domain_in_{{host}}
......
......@@ -3,11 +3,13 @@
{% endfor %}
{% for drupal in hostvars[item].drupal_settings|default([]) %}
{% for domain in drupal.domains|default([]) %}
{% if domain.route_by_domain|default(true) %}
{% if domain.protocol|default('https') == 'http' %}
{{domain.domain}}
{% for alias in domain.aliases|default([]) %}
{{alias}}
{% endfor %}
{% endif %}
{% endif %}
{% endfor %}
{% endfor %}
......@@ -3,11 +3,13 @@
{% endfor %}
{% for drupal in hostvars[item].drupal_settings|default([]) %}
{% for domain in drupal.domains|default([]) %}
{% if domain.route_by_domain|default(true) %}
{% if domain.protocol|default('https') == 'https' %}
{{domain.domain}}
{% for alias in domain.aliases|default([]) %}
{{alias}}
{% endfor %}
{% endif %}
{% endif %}
{% endfor %}
{% 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