Can Varnish do this?

Rob S rtshilston at gmail.com
Wed Jul 7 08:49:58 CEST 2010


Angelo Höngens wrote:
>> On Wed, Jul 7, 2010 at 12:10 AM, zabrane Mikael <zabrane3 at gmail.com>
>> wrote:
>>     
>>> Hi List,
>>> I'm new to Varnish,...Thanks in advance.
>>>       
>
> So basically what you want to do is define two backends, and if your custom header is present in the request, you want it to go to one backend, and if not, you want to go to the other backend.
>   

You'd write something like:

backend normalhttp { .host = "a.b.c.d"; .port="80"; }
backend customserver { .host = "w.x.y.z"; .port="80"; }


sub vcl_recv {

    // Set the default backend:
    set req.backend = normalhttp;

    // But override it if this is a request containing X-RAWDATA
    if (req.http.X-RAWDATA!="") {
        set req.backend = customserver;
    }

    ...


This code above isn't tested, but we use a similar approach happily in 
production.  We inspect the http host, and redirect certain hosts to 
different backend director pools.

Good luck!




More information about the varnish-misc mailing list