Reve,

On 2012-07-28 19:46, Reve wrote:
> let's say I have this URL
> /blah?x1=5&x2=-5&y1=-1&y2=50
>
> I want to go to a different set of backends if 
> x1<0, y1<0 -> backends set 1
> x1<0, y1>0 -> backends set 2
> x1>0, y1<0 -> backends set 3
> x1>0, y1>0 -> backends set 4

You can't actually parse the URL and match the numbers as integers.
However, you can use match the URL as a string and apply regular
expressions for your conditions.

acl x1_lt_0 url_reg [?&]x1=-\d+
acl x1_gt_0 url_reg [?&]x1=[1-9][0-9]*
acl y1_lt_0 url_reg [?&]y1=-\d+
acl y1_gt_0 url_reg [?&]y1=[1-9][0-9]*

use_backend backend_set_1 if x1_lt_0 y1_lt_0
use_backend backend_set_2 if x1_lt_0 y1_gt_0
use_backend backend_set_3 if x1_gt_0 y1_lt_0
use_backend backend_set_4 if x1_gt_0 y1_gt_0

The ACLs match the simplest possible case. There are some cases where
they might match too much or too less, e.g. when your parameters can
start with a number and end with a string or when you have multiple
question marks. If required, you can adapt the regexes and make them
arbitrarily complex.

However, you should probably not uses these rules for securing the
access but only to make a routing decision. Your backend services should
then make sure that the provided URL parameters are actually sound.

For more information about ACL matching, have a look at the documentation at

* http://haproxy.1wt.eu/download/1.4/doc/configuration.txt (authoritative)
* http://cbonte.github.com/haproxy-dconv/configuration-1.4.html#7 (readable)

--Holger

(meh, missed the mailing list, resending there)

Reply via email to