Redirecting based on http verb and URL
Davies Matt J A (LCSS)
mjdavies at glam.ac.uk
Wed Jul 21 14:13:13 CEST 2010
Hello everyone
I'm just checking I'm going down the right path here.
I've read the example redirect section on the docs here, http://varnish-cache.org/wiki/VCLExampleRedirectInVCL
In my case we've just moved web sites, and some crazy dudes are spamming our site, trying to send a POST form to an one page that may have one time allowed it.
My Rails app is picking up these attempts at spam and throwing them out, but I want to handle them, and other normal people who simply click on the old link somewhere, with varnish prior to that.
Here's my addition to the vcl_recv
if (req.http.host == "^(www.)?webiste/blogs/oldpage$") {
error 750 "Moved Temporarily";
if (req.request == "POST"){
error 751 "Please go away"
}
}
and vcl_error
sub vcl_error {
if (obj.status == 750) {
set obj.http.Location = "http://newblogs";
set obj.status = 302;
deliver;
}
if (obj.status == 751) {
set obj.status = 500;
deliver;
}
}
Can anyone see any glaringly obvious stupid bits in there?
Thanks again.
More information about the varnish-misc
mailing list