It's possible to have dinamic backends?

Kacper Wysocki kacperw at
Sat Sep 11 17:38:01 CEST 2010

2010/9/10 Nils Goroll <slink at>:
> Hi Guillermo,
>> So, going back to the point, there is any way of configuring the host
>> to use for a request, without it being defined in the backends
>> section? I can generate the IP if needed.
> I usually use perl code to generate the VCL, that way can just generate the
> backend selector
>        if (req.http.X-Panel = "1") {
>                set req.backend = server1;
>        } else if (req.http.X-Panel = "2") {
>                set req.backend = server2;
> ....
> An alternative is the VSLP director I have written. I haven't published it yet,
> as I have quite a lot of open tickets with patches I proposed, and I don't see
> much value in preparing patches if the core developers don't have enough
> resources to review them. The director is ready, I am using it in production on
> a high traffic site.

Nils: this VSLP director of yours looks fairly interesting, but maybe
you could post a {patch,github repo,other source} so that people can
look at it instead of reimplementing their own versions?

Guillermo: we accidentally slipped off list, that wasn't intentional
so here we are again. Your approach seems reasonable given the DNS
redirector design. This will let DNS pick the backend and varnish will
cache the response, that might make it a little more manageable.


---------- Forwarded message ----------
From: Guillermo Pérez <bisho at>
Date: 2010/9/10
Subject: Re: It's possible to have dinamic backends?
To: Kacper Wysocki <kacperw at>

> Hi Guillermo,
> the short answer is no but you can use the DNS director for this if
> your backends are on the same subnet. Varnish must have a backend
> object per backend, and the dns director list will spawn them for you.
> Otherwise I'd suggest you can have a script generate and reload the
> VCL for backend definitions.

Yeah, that may work! If I rewrite the host, then the dns director will
make the resolution of the rewrited domain, won't it?

sub vcl_recv {
               if (get_server_for_url) {
                       VRT_SetHdr(sp, HDR_REQ, "\010X-Panel:", sprintf(

       set req.backend = dnsbackend;
       set = req.http.X-Panel;

director dnsbackend dns {
   .list = {
       .port = "80";
       .connection_timeout = 0.4;
   .ttl = 5m;

I'lll give it a try,

Thanks a lot!

Guille -ℬḭṩḩø- <bisho at>

> In
> I have described the basic design.
> IIUC, the VSLP director would do what you need. VCL inline code would look
> something like
>        C{
>                if (get_server_for_url) {
>                        /* pseudo-VCL: set dir.key = get_server_for_url(req.url) */
>                        VRT_l_dir_key_int(sp, get_server_for_url(VRT_r_req_url(sp)));
>                }
>        }C
> Server selection is then as
>        server = key % nservers
> nserver being the number of servers, plus additional logic when the server is
> down etc.
> Nils
> _______________________________________________
> varnish-dev mailing list
> varnish-dev at

Employ no technique to gain supreme enlightment.
- Mar pa Chos kyi blos gros

More information about the varnish-dev mailing list