A lot of if statements to handle hostnames
Paul Lu
paul.lu81 at gmail.com
Tue Mar 8 18:50:44 CET 2011
Primarily just to make the code cleaner and a little concerned if I have a
lot of hostnames. 100 for example. Having to potentially traverse several
if statements for each request seems inefficient to me.
Thank you,
Paul
On Mon, Mar 7, 2011 at 11:32 PM, Indranil Chakravorty <
indranilc at rediff-inc.com> wrote:
> Apart from improving the construct to if ... elseif , could you please tell
> me the reason why you are looking for a different way? Is it only for ease
> of writing less statements or is there some other reason you foresee? I am
> asking because we also have a number of similar construct in our vcl.
> Thanks.
>
> Thanks,
> Neel
>
> On Tue, 08 Mar 2011 12:31:11 +0530 Paul Lu <paul.lu81 at gmail.com> wrote
>
> >Hi,
> >
> >I have to work with a lot of domain names in my varnish config and I was
> wondering if there is an easier to way to match the hostname other than a
> series of if statements. Is there anything like a hash? Or does anybody have
> any C code to do this?
> >
> >example pseudo code:
> >=================================
> >vcl_recv(){
> >
> > if(req.http.host == "www.domain1.com")
> > {
> > set req.backend = www_domain1_com;
> > # more code
> > return(lookup);
> > }
> > if(req.http.host == "www.domain2.com")
> > {
> > set req.backend = www_domain2_com;
> > # more code
> > return(lookup);
> > }
> > if(req.http.host == "www.domain3.com")
> > {
> > set req.backend = www_domain3_com;
> > # more code
> > return(lookup);
> > }
> >}
> >=================================
> >
> >Thank you,
> >Paul
> > _______________________________________________
> > varnish-misc mailing list
> > varnish-misc at varnish-cache.org
> > http://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.varnish-cache.org/lists/pipermail/varnish-misc/attachments/20110308/480ecc73/attachment-0003.html>
More information about the varnish-misc
mailing list