On Mon, Nov 23, 2015 at 10:52 AM, Dennis Jacobfeuerborn <denni...@conversis.de> wrote: > Hm, I wasn't aware of the -M flag, thanks! > > However in you example you again you have to do multiple lookups even > though that shouldn't be necessary. I can make decisions based on the > fact that the IP is present in the map but what I really want to do is > make a decision based on what the actual value for that IP in the map is > i.e. if the value is "de" then I want to do one thing and if it is "at" > then I want to do something else. > > Regards, > Dennis >
I see. I believe you could accomplish what you want with something like http-request set-var(req.ip_lookup) src,map_ip(<map-file-1>) http-request set-header X-Test wasxx if { var(req.ip_lookup) -m str xx } http-request set-header X-Test wasyy if { var(req.ip_lookup) -m str yy } http-request set-var is new in HAProxy 1.6. Also note the implicit ACL definition with '{}' - that's syntactic sugar so you don't have to declare them before (which would be very verbose). That said, the difference between one and two map lookups is negligible, so I don't think you're saving much this way and it'll make configuration harder in some ways if you keep adding IPs. I can vouch from personal experience in production that we run 2+ map lookups on every request at Braintree (hundreds of req/s) and it adds no noticeable latency. Food for thought. :) http://cbonte.github.io/haproxy-dconv/configuration-1.6.html#http-request (especially note the section about variable scope). -- - Andrew Hayworth