Commit 803db3c6 authored by Per Andreas Buer's avatar Per Andreas Buer

Bans via VCL/HTTP

git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@4948 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent ef60386b
......@@ -352,7 +352,7 @@ Support for bans is built into Varnish and available in the CLI
interface. For VG to ban every png object belonging on vg.no they could
issue:::
purge req.http.host ~ ^vg.no && req.http.url ~ \.png$
purge req.http.host == "vg.no" && req.http.url ~ "\.png$"
Quite powerful, really.
......@@ -361,4 +361,22 @@ deliver it. An object is only checked against newer bans. If you have
a lot of objects with long TTL in your cache you should be aware of a
potential performance impact of having many bans.
You can also add bans to Varnish via HTTP. Doing so requires a bit of VCL.::
sub vcl_recv {
if (req.request == "BAN") {
# Same ACL check as above:
if (!client.ip ~ purge) {
error 405 "Not allowed.";
}
purge("req.http.host == " req.http.host
"&& req.url == " req.url);
# Throw a synthetic page so the
# request wont go to the backend.
error 200 "Ban added"
}
}
This VCL sniplet enables Varnish to handle a HTTP BAN method. Adding a
ban on the URL, including the host part.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment