agaric-coop/box/provisioning/roles/geerlingguy.varnish/templates/default.vcl.j2

39 lines
1 KiB
Text
Raw Permalink Normal View History

{% if varnish_version | version_compare('4.0', '>=') %}
vcl 4.0;
{% endif %}
# This is a basic VCL configuration file for varnish. See the vcl(7)
# man page for details on VCL syntax and semantics.
#
# Default backend definition. Set this to point to your content
# server.
backend default {
.host = "{{ varnish_default_backend_host }}";
.port = "{{ varnish_default_backend_port }}";
}
{% if varnish_backends is defined %}
# Other backend servers.
{% for backend, value in varnish_backends.iteritems() %}
backend {{ backend }} {
.host = "{{ value.host }}";
.port = "{{ value.port }}";
}
{% endfor %}
{% endif %}
sub vcl_recv {
{% if varnish_vhosts is defined %}
# Varnish vhosts.
{% for vhost, value in varnish_vhosts.iteritems() if varnish_vhosts is defined %}
{% if loop.first %}
if (req.http.host == "{{ vhost }}" || req.http.host == "www.{{ vhost }}") {
{% else %}
elseif (req.http.host == "{{ vhost }}" || req.http.host == "www.{{ vhost }}") {
{% endif %}
set req.backend_hint = {{ value.backend }};
}
{% endfor %}
{% endif %}
}