Varnish - set backend if statuscode is 404
Stefan Caunter
stef at scaleengine.com
Fri Nov 29 14:29:39 CET 2013
On Fri, Nov 29, 2013 at 7:15 AM, Jan-Frode Myklebust <janfrode at tanso.net> wrote:
> On Fri, Nov 29, 2013 at 09:06:15AM +0100, Per Buer wrote:
>> >
>> > @per, you suggested saint mode. Why? What would it do better than Tobias'
>> > solution?
>>
>> Saint mode works if you have two backends in the same director. Then it
>> blacklists that object from that backend for a certain time. A restart
>> would then direct the request to the other backend.
>>
>> Tobias solution is to have two backends. The other one is only used when
>> the first one fails.
>>
>
> Ideally we want both. Our two hosts in the director are fully
> functional, but one of them might not have received a given file yet. So
> we want to try the other backend in the director, not mark it as faulty
> when it gets the 404.
>
> Do you see any way to maybe combine Tobias' solution with a director?
>
in fetch
if (beresp.status == 404) {
set beresp.http.X-Some-Edge-Restart = "True " beresp.status;
set beresp.ttl = 0s;
restart;
}
in recv
if (req.restarts == 0) {
set req.backend = b1;
}
if (req.restarts == 1) {
set req.backend = b2;
}
if (req.restarts == 2) {
set req.backend = b3;
}
if (req.restarts == 3) {
set req.backend = b4;
}
}
we use this for a particular case where each backend has unique
content, and we want varnish to be point of access for application
varnish goes and gets the file from any of the possible locations
which is faster than trying to create an authoritative archive with
rsync or some other silly solution
----
Stefan Caunter
E: stefan.caunter at scaleengine.com
Toronto Canada
More information about the varnish-misc
mailing list