there is a typo, a / missing before 'api' in path_beg: acl is_api hdr_beg(host) -i api acl is_api path_beg -i /api acl somewhere hdr_sub(host) -i .somewhere. use_backend api if is_api use_backend www if somewhere
Maybe it does not work because of the rest of your configuration... Please paste the whole configuration. Baptiste On Thu, Dec 12, 2013 at 2:37 PM, Athanasios | ZenGuard <[email protected]> wrote: > Dear all, > thanks for your input. I tried baptiste's configuration and it did not solve > my problem. I have a feeling we are getting there (we already kill a bug). > Any further ideas would be more than welcome :) > > > On Thu, Dec 12, 2013 at 2:29 PM, Baptiste <[email protected]> wrote: >> >> On Thu, Dec 12, 2013 at 12:35 PM, Athanasios | ZenGuard >> <[email protected]> wrote: >> > Dear HAProxy list, >> > I have a question regarding ACL logic. >> > First of all some background to my predicament: >> > recently we switched to different API and WWW slices. Usually, updated >> > clients will call api.somewhere for API and www.somewhere for WWW. This >> > holds true for 90% of the cases. A number (let's say 10%) have not >> > updated >> > their clients yet and they use the old scheme somewhere/api/etc to >> > access >> > the API. I am trying to provide a hotfix for that using HAProxy. Here is >> > my >> > relevant configuration which does NOT work: >> > >> > acl is_api hdr_beg(host) -i api or path_beg -i api >> > acl is_www hdr_dom(host) -i www.somewhere >> > use_backend api if is_api >> > use_backend www if is_www >> > use_backend www if !is_api >> > >> > the problem is that when I curl www.somewhere/api/etc, HAProxy will use >> > the >> > is_www ACL, resulting in a 404 (and a non-working client for the >> > minority of >> > the users). >> > >> > Any input on how can I fix that would be more than welcome :) >> >> >> Hi, >> >> The OR function in acls doesn't work as you expected it to do. >> Here, you're looking for either api, or, path_beg, -i, api => all of >> them in the beginning of the host header. >> >> You can give a try to the configuration below: >> acl is_api hdr_beg(host) -i api >> acl is_api path_beg -i api >> acl is_www hdr_sub(host) -i .somewhere. >> use_backend api if is_api >> use_backend www if is_www OR !is_api >> >> Baptiste > >

