Thanks willy, I need to do more than just pick a backend. So you feel even with a map of 10K keys, multiple look ups should be ok?
Thanks Sachin On 12/8/14 6:15 PM, "Willy Tarreau" <w...@1wt.eu> wrote: >Hi Sachin, > >On Mon, Dec 08, 2014 at 06:04:35PM +0530, Sachin Shetty wrote: >> Hi Willy, >> >> I need one more clarification, I need the value in multiple acls >> >> acl is_a_v-1 hdr(host),map(/opt/haproxy/current/conf/proxy.map) a_v-1 >> >> acl is_a_v-2 hdr(host),map(/opt/haproxy/current/conf/proxy.map) a_v-2 >> >> acl is_a_v-3 hdr(host),map(/opt/haproxy/current/conf/proxy.map) a_v-3 >> .. >> .. >> acl is_a_v-10 hdr(host),map(/opt/haproxy/current/conf/proxy.map) a_v-10 >> >> >> is there a way I could lookup once and use the values in multiple acls? > >There would be an option for this. Using a capture would permit to >have a temporary variable containing the result of your map. Something >like this approximately : > > tcp-request inspect-delay 10s > tcp-request capture >%[hdr(host),map(/opt/haproxy/current/conf/proxy.map)] len 40 > >Then your ACLs can refer to capture.req.hdr(0) (assuming it's the first >"capture" rule) : > > acl is_a_v-1 capture.req.hdr(0) a_v-1 > acl is_a_v-2 capture.req.hdr(0) a_v-2 > acl is_a_v-3 capture.req.hdr(0) a_v-3 > ... > >Note that when using rules as yours above (string-to-string mapping), the >lookup is very fast, only the header extraction costs a little bit, so you >should not be worried by these few rules. If you would use >case-insensitive >match or regex match, it would be different and you'd really need this >optimization. > >If you only want to use these rules to select a proper backend, you could >also use the dynamic use_backend rules (but please carefully read the doc >about use_backend and maps for the details) : > > use_backend %[hdr(host),map(proxy.map)] > >And you don't need any acl anymore, and everything is done in a single >lookup. > >Regards, >Willy >