diff --git a/tasks/configure.yml b/tasks/configure.yml index 15adde2fdc18a8f90122bf460980703afe9588ad..8a3b9d55d7992edfc40fb282affa51e242099c95 100644 --- a/tasks/configure.yml +++ b/tasks/configure.yml @@ -29,6 +29,15 @@ with_items: '{{ groups.all }}' notify: 'Proxy | Restart HAProxy' +- name: "Proxy | Create ignore varnish host lists" + template: + src='ignore_varnish_list' + dest='/etc/haproxy/ignore_varnish.list' + owner='root' + group='root' + mode='644' + notify: 'Proxy | Restart HAProxy' + - name: "Proxy | Create empty crm lists files" file: dest='/etc/haproxy/{{item}}.crm.list' diff --git a/templates/haproxy_cfg b/templates/haproxy_cfg index 4e49002673c5fce2cbeaf6278582f11c12a4b6f7..c0a61d1df74b8f491db9baf274c95f3b0f0b14c7 100644 --- a/templates/haproxy_cfg +++ b/templates/haproxy_cfg @@ -84,8 +84,9 @@ frontend http_in use_backend backend_redirect_ssl if kibana_present {% endif %} {% if varnish_host|default(false) %} + acl domain_ignores_varnish hdr(host) -i -n -f /etc/haproxy/ignore_varnish.list acl static_content path_end .jpg .jpeg .gif .png .ico .swf .css .js .htm .html - use_backend backend_varnish if static_content + use_backend backend_varnish if static_content !domain_ignores_varnish {% endif %} {% for host in groups['all'] %} acl domain_in_{{host}} hdr(host) -i -n -f /etc/haproxy/{{host}}.list @@ -137,8 +138,9 @@ frontend https_in_{{ cert.ip }} use_backend backend_{{ external.key }} if is_{{ external.key }} {% endfor %} {% if varnish_host|default(false) %} + acl domain_ignores_varnish hdr(host) -i -n -f /etc/haproxy/ignore_varnish.list acl static_content path_end .jpg .jpeg .gif .png .ico .swf .css .js .htm .html - use_backend backend_varnish if static_content + use_backend backend_varnish if static_content !domain_ignores_varnish {% endif %} {% for host in groups['all'] %} acl ssl_domain_in_{{host}} hdr(host) -i -n -f /etc/haproxy/{{host}}.ssl.list diff --git a/templates/ignore_varnish_list b/templates/ignore_varnish_list new file mode 100644 index 0000000000000000000000000000000000000000..207c9cc375f4392d46fec3db33415d316f8de533 --- /dev/null +++ b/templates/ignore_varnish_list @@ -0,0 +1,12 @@ +{% for item in groups.all %} +{% for domain in hostvars[item].proxy_domains_ignore_varnish|default([]) %} +{{domain}} +{% endfor %} +{% for drupal in hostvars[item].drupal_settings|default([]) %} +{% for domain in drupal.domains|default([]) %} +{% if domain.ignore_varnish|default(false) %} +{{domain.domain}} +{% endif %} +{% endfor %} +{% endfor %} +{% endfor %}