vcl newbie question
Fred Clift
fred at clift.org
Thu Jun 28 00:36:14 CEST 2012
I'm going to have many domains being proxied by varnish and I'd like
to be able to invalidate by doing a PURGE on a different IP than the
domain...
At system startup, and as an emergency tool for system administrators,
I BAN entire domains.
For my whole-domain BANs my vcl looks like:
# allow HOSTBAN from localhost and hosts in purge acl
# HOSTBAN covers entire domain
if (req.request == "HOSTBAN") {
# Same ACL check as above:
if (!client.ip ~ purge) {
error 405 "Not allowed.";
}
std.log("trying to ban " + req.url);
ban("req.http.host == " + req.url);
# Throw a synthetic page so the
# request won't go to the backend.
error 200 "Ban added";
}
and my python code does the following:
def do_hostban(cachehost, domain):
conn = httplib.HTTPConnection(cachehost)
conn.request("HOSTBAN", domain)
rl = conn.getresponse()
conn.close()
debugprint( "%s %s" % (rl.status, rl.reason))
return rl.status, rl.reason
do_hostban("cacheIP", "www.bandomain.com")
This does approximately the same as you can with curl, without all
that nasty shell interpolation:
/usr/bin/curl -s -X HOSTBAN "http://cacheIP/www.bandomain.com"
I'd like to keep the cache host/ip separate from the domain(s) being
hosted so that I could proxy or aggregate these at some central point
(from several servers) without having to change much.
So, my real problem is that I really only have a very superficial
understanding of vcl. for purges I have:
sub vcl_recv {
# allow PURGE from localhost and hosts in purge acl
# PURGE does a single, unique URL (+Vary-iants)
if (req.request == "PURGE") {
if (!client.ip ~ purge) {
error 405 "Not allowed.";
}
return (lookup);
}
}
sub vcl_hit {
if (req.request == "PURGE") {
purge;
error 200 "Purged.";
}
}
sub vcl_miss {
if (req.request == "PURGE") {
purge;
error 200 "Purged.";
}
}
How would I modify this code so that I could purge via approximately
the following syntax?
http://varnishIP/www.purgedomain.com/some/url.php
I've stared at the docs for a while, and ended up going back t work on
other parts of my project while hoping for enlightenment.
Fred
More information about the varnish-misc
mailing list