backend b1 {
.host = "fs.freebsd.dk";
.port = "82";
}
backend b2 {
.host = "fs.freebsd.dk";
.port = "81";
}
backend b3 {
.host = "fs.freebsd.dk";
.port = "80";
}
sub vcl_recv {
if (req.restarts == 0) {
set req.backend = b1;
} else if (req.restarts == 1) {
set req.backend = b2;
} else {
set req.backend = b3;
}
}
sub vcl_fetch {
## If the request to the backend returns a code other than 200, restart the loop
## If the number of restarts reaches the value of the parameter max_restarts,
## the request will be error'ed. max_restarts defaults to 4. This prevents
## an eternal loop in the event that, e.g., the object does not exist at all.
if (obj.status != 200 && obj.status != 403 && obj.status != 404) {
restart;
}
}
Pages that return a "403: Forbidden" or "404: Missing" error will cause a fault in the current trunk version of varnishd (see 280), thus the vcl_fetch section of this configuration must specifically exempt that error code.
