Please see: https://www.varnish-software.com/blog/ban-lurker
Please see: http://kristianlyng.wordpress.com/2010/07/28/smart-bans-with-varnish/
The current ban method uses req.host and req.url on sites with lower traffic to pages bans can be able to stay in the system especially when used with the expire module with expiring taxonomy and referring pages each new post, delete, etc can cause a new ban to be listed in Varnish. Each ban can not expire until every page in the cache has been looked up. In the case of req.url/req.host this means a end user must visit the page before it can be expired from the cache.
The patch attached adds a new option to the admin interface to allow choosing normal req.host/req.url or instead use obj.http.x-host/obj.http.x-url which is Ban Lurker comptatible.
Please note this is my first Drupal project patch so I apologies if anything in the patch is out of spec to standards.
No simpletest items were added I am not sure if this is the sort of thing that needs a test or not?
I called the Ban types: “Normal” and “Ban Lurker” I am open to different names. Possible other names options could be “req.http.host/req.http.url" and "obj.http.x-host/obj.http.x-url" (this also opens the possibility of a different patch that removes host all together for sites that don't normalize their hostnames but that is a different discussion)
VCL mods are needed if you use the Ban Lurker.
sub vcl_fetch {
set obj.http.x-host = req.host;
set obj.http.x-url = req.url;
}
sub vcl_deliver {
unset resp.http.x-host; # Optional
unset resp.http.x-url; # Optional
}
Note: So long as VCL mods are done user can use x-url x-host based bans even if they do not use Ban Lurker.
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | varnish-supportbanlurker-1423560-5.patch | 2.51 KB | cmlara |
| #4 | varnish-supportbanlurker-1423560-4.patch | 2.53 KB | neilnz |
| varnish-supportbanlurker.patch | 2.46 KB | cmlara |
Comments
Comment #1
fabsor commentedThis looks like an awesome feature. I will look into this soon!
Comment #2
Steven Merrill commented+1 - This is a much better option if you will be clearing Varnish a lot.
Other than having to manually apply one hunk, this patch works well against 7.x-1.0-beta1.
Comment #3
cmlaraHello Steven,
Thanks for the heads up on 7.x.
I planned on rolling a patch to 7.x once it was accepted into the 6.x code base so good to hear that it works on the latest beta.
I just did a preliminary look at the 7.x and see where it needs to be dropped in. Once this gets Status: Patch (To be ported) I will post the 7.x version.
Testing note:
Its only on my LAB server right now but so far so good no issues have shown up over the past month and my ban list isn't growing so it looks like as expected the commands are flowing and varnish is honoring them correctly.
Comment #4
neilnz commentedThis patch works as advertised (testing on Varnish 3.0.2).
Probably some documentation would be in order though. I've revised the patch to correctly use its own default and provide minimal instructions in the #description of the config form field.
Comment #5
fabsor commentedThanks for reviewing and testing, this is really awesome! Commited to 6.x, now it's time for D7.
http://drupal.org/commitlog/commit/11214/8244d9a70dcd0ab27171396908c1c4f...
Comment #6
cmlaraSorry for the delay.
As promised here is a patch for 7.x
As mentioned in comment 2 it only needed a manual apply of one hunk of data (in varnish.admin.inc) the other two hunks went in by via diff.
Comment #7
cmlaraI noticed one item just now.
the documentation part was written as:
"Ban lurker support requires you to add beresp.http.x-url and beresp.http.x-host entries to the response in vcl_fetch."
The module actually uses obj.*
Question is did I miss an item between say a version Varnish 2.x and a Varnish 3.x CLI command (I run 3.x) or is this just a writeup error?
(Either case will require a new back port of a correction into the commit in comment 5 after we decide in the 7x tree)
EDIT: March 25th at 0752 GMT
Sorry, VCL file really does have "set beresp" in it...... I was mixing up Varnish CLI and Varnish VCL files....
Disregard this Comment.
Comment #8
neilnz commentedFor the ban itself, obj.* is used, but in order to make it work, at least in Varnish 3, it's beresp that needs to be set in vcl_fetch to accomplish it:
sub vcl_fetch {
...
set beresp.http.x-url = req.url;
set beresp.http.x-host = req.http.host;
...
}
I believe in Varnish 2 vcl_fetch works on obj rather than beresp, but I'm not sure as I never worked with V2.
Comment #9
cmlaraAnyone verified the patch in msg 6? If so can this get mark community reviewed for committing?
Per standard it would be inappropriate for me to mark it myself.
Comment #10
fabsor commentedThe patch seems to work fine, and we want to move forward with this, so I'm commiting it. Thanks for your work!