Re: A lot of if statements to handle hostnames

Indranil Chakravorty indranilc at rediff-inc.com
Tue Mar 8 08:32:53 CET 2011


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/170e5403/attachment-0003.html>


More information about the varnish-misc mailing list