Varnish - set backend if statuscode is 404
Jan-Frode Myklebust
janfrode at tanso.net
Thu Nov 28 16:15:35 CET 2013
If you manage to do this, I would much appreciate you post a recipie :-)
I've been struggeling trying to achieve the same thing, without
success..
Actually my setup is a bit different, we have a director, and just want
to check the other backend if the first backend gives 404, but the same
solution might apply.
backend backend1 {
.host = "backend1.example.com";
.probe = {
.url = "/alive.html";
.timeout = 34 ms;
.interval = 2s;
.window = 10;
.threshold = 8;
}
}
backend backend2 {
.host = "backend2.example.com";
.probe = {
.url = "/alive.html";
.timeout = 34 ms;
.interval = 2s;
.window = 10;
.threshold = 8;
}
}
director dir1 client {
{ .backend = backend1; .weight = 1; }
{ .backend = backend2; .weight = 1; }
}
sub vcl_recv {
if ( req.http.host ~ "(?i)www.example.com$" ) {
set req.backend = dir1;
return(lookup);
}
}
-jf
More information about the varnish-misc
mailing list