r4948 - trunk/varnish-cache/doc/sphinx/tutorial
perbu at varnish-cache.org
perbu at varnish-cache.org
Fri Jun 11 11:07:35 CEST 2010
Author: perbu
Date: 2010-06-11 11:07:34 +0200 (Fri, 11 Jun 2010)
New Revision: 4948
Modified:
trunk/varnish-cache/doc/sphinx/tutorial/increasing_your_hitrate.rst
Log:
Bans via VCL/HTTP
Modified: trunk/varnish-cache/doc/sphinx/tutorial/increasing_your_hitrate.rst
===================================================================
--- trunk/varnish-cache/doc/sphinx/tutorial/increasing_your_hitrate.rst 2010-06-10 21:19:45 UTC (rev 4947)
+++ trunk/varnish-cache/doc/sphinx/tutorial/increasing_your_hitrate.rst 2010-06-11 09:07:34 UTC (rev 4948)
@@ -352,7 +352,7 @@
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 @@
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.
More information about the varnish-commit
mailing list