{% extends "varnish-bans-manager/core/bans/layout.html" %} {% load i18n %} {% load vbm_widget_helpers %} {% load vbm_form_helpers %} {% block title %}{% trans 'Bans' %} > {% trans 'Expert' %}{% endblock %} {% block sidebar_section %}expert{% endblock %} {% block sidebar_content %}

{% trans 'Set and submit your ban' %}

{% form_cgroup form.ban_expression 'span12' %} {{ form.ban_expression.label_tag }}
{{ form.ban_expression|add_class:"span12" }}
{% form_ferrors form.ban_expression 'block' %} {% endform_cgroup %}
{% form_cgroup form.target 'span6' %} {{ form.target.label_tag }}
{{ form.target|add_class:"span12" }}
{% form_ferrors form.target 'block' %} {% endform_cgroup %}

{% trans 'Ban expressions' %}

{% blocktrans with 'https://www.varnish-cache.org/docs/trunk/reference/varnish-cli.html#ban-expressions' as exprs %}A ban expression may be composed of several conditions combined using a logical AND operator (&&). Each condition should consist of a field, an operator and an argument.{% endblocktrans %}

{% trans 'Examples' %}

  1. {% trans 'To ban a particular content (requested URL):' %}

    req.url == /path/to/content

  2. {% trans 'To ban all PDF files in the virtual host example.com:' %}

    req.url ~ "\\.pdf$" && req.http.host == example.com

  3. {% blocktrans with 'https://www.varnish-software.com/blog/ban-lurker' as lurker %}Same as before but using a lurker friendly ban (recommended approach that requires some tunning of the VCL):{% endblocktrans %}

    obj.http.x-url ~ "\\.pdf$" && obj.http.x-host == example.com

{% endblock %}