On 2010-02-04 21:15, Sriram Chavali wrote:
> I am trying to rewrite URLs using haproxy's reqirep directive. The url that I am trying to rewrite is of the pattern
> /action/register?param1=foo¶m2=bar¶m3=baz
>
> The URL that I want to be rewritten is
> /newaction?param1=foo¶m2=bar¶m3=baz on the condition that whenever param2=bar
>
> The ordering of the query string parameters can be random, i.e param2 could be the 1st parameter or the last one.
In Haproxy 1.3.x it is currently not possible to issue a reqirep on a
conditional basis. This is however introduced in Haproxy 1.4-rc1. There
you could solve your problem using something like this:
acl baz url_sub ¶m2=bar ?param2=bar
reqirep ([^\ ]*)\ /action/register\?(.*) \1\ /newaction\?\2 if baz
On 1.3.x you could however use something like the following which
performs a content switch based on the acl and performs the reqirep
later in the backend. You might want to look into the track keyword for
the servers.
frontend foo
bind :80
mode http
acl baz url_sub ¶m2=bar ?param2=bar
use_backend baz if baz
backend baz
reqirep ([^\ ]*)\ /action/register\?(.*) \1\ /newaction\?\2
server foo 192.168.1.1:80
Yes, this is uggly but as far as I know it is the only possibility by
now. (And yes, I see forward to remove many such backends in my
installations too)
--Holger