It's possible to have dinamic backends?
Kacper Wysocki
kacperw at online.no
Sat Sep 11 17:38:01 CEST 2010
2010/9/10 Nils Goroll <slink at schokola.de>:
> 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.
-K
---------- Forwarded message ----------
From: Guillermo Pérez <bisho at tuenti.com>
Date: 2010/9/10
Subject: Re: It's possible to have dinamic backends?
To: Kacper Wysocki <kacperw at online.no>
> 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 {
C{
if (get_server_for_url) {
VRT_SetHdr(sp, HDR_REQ, "\010X-Panel:", sprintf(
"%s.imgs.tuenti.int",
get_server_for_url(VRT_r_req_url(sp)))
);
}
}C
set req.backend = dnsbackend;
set req.http.host = req.http.X-Panel;
director dnsbackend dns {
.list = {
.port = "80";
.connection_timeout = 0.4;
"192.168.0.0"/24;
}
.ttl = 5m;
}
I'lll give it a try,
Thanks a lot!
--
Guille -ℬḭṩḩø- <bisho at tuenti.com>
:wq
>
> In
> http://lists.varnish-cache.org/pipermail/varnish-dev/2010-March/002420.html
> 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 varnish-cache.org
> http://lists.varnish-cache.org/mailman/listinfo/varnish-dev
>
>
--
http://kacper.doesntexist.org
http://windows.dontexist.com
Employ no technique to gain supreme enlightment.
- Mar pa Chos kyi blos gros
More information about the varnish-dev
mailing list