Multiple reqirep statements in frontends and backends

From: Shawn Heisey <haproxy#elyograg.org>
Date: Wed, 15 Dec 2010 15:32:23 -0700


I buried this email deep in another thread, bringing it back to the top with a new message.

I have a bunch of rewrites that I need to do to incoming requests. I tried initially putting them all in the frontend, but that didn't work. What finally worked was creating multiple backends, each with one reqirep in it and the same pair of server entries in all of them. Is it a known limitation that only one reqrep/reqirep statement is allowed?

Is there a way to streamline my configuration so that I only have to define the server list once? Can you put multiple reqirep statements in the backend? I haven't tried this yet because they won't let me risk breaking it for a day or two.

Management is actually likely to want to keep the multiple backends in place because it does give a wealth of information on the stats page, but I would like to avoid the config duplication. I did see that the latest dev version lets you include external files in the config, which could be one way to deal with this.

Another notion would be the ability to chain backends ... your frontend has use_backend, where you do rewrites or whatnot. With this ability, you would put another use_backend statement in the first backend to point it at the final section that has the server definitions. Yet another approach - create an option to define macros or substitution variables that you can specify in your config sections.

Thoughts?



frontend foo *:80

     acl bot hdr_sub(User-Agent) -i ia_archiver jeeves googlebot mediapartners-google msnbot slurp zyborg

     acl foo       path_beg        -i /foo/
     acl fooc      path_beg        -i /fooc/
     acl fooh      path_beg        -i /fooh/
     acl foothumb  path_beg        -i /foothumb/
     acl featured  path_beg        -i /featured/foothumbnew/
     acl cgi       path_beg        -i /cgi-bin/cgi-gw.exe

     use_backend apache_fooh     if bot fooh
     use_backend apache_foo      if foo
     use_backend apache_fooc     if fooc
     use_backend apache_foothumb if foothumb
     use_backend apache_featured if featured
     use_backend apache          if cgi
     default_backend             tomcat

backend tomcat
     balance     leastconn
     server      server8080 10.10.14.127:8080 check
     server      server8081 10.10.14.127:8081 backup check

backend apache
     balance     leastconn
     server      server8080 10.10.14.127:8080 check
     server      server8081 10.10.14.127:8081 check

backend apache_foo
     reqirep ^([^\ ]*)\ /foo/(.*) \1\ 

/cgi-bin/cgi-gw.exe?action=webres&fooid=\2
balance leastconn server server8080 10.10.14.127:8080 check server server8081 10.10.14.127:8081 check backend apache_fooh reqirep ^([^\ ]*)\ /fooh/(.*) \1\
/cgi-bin/cgi-gw.exe?action=autodetails&fooid=\2
balance leastconn server server8080 10.10.14.127:8080 check server server8081 10.10.14.127:8081 check backend apache_fooc reqirep ^([^\ ]*)\ /fooc/(.*) \1\
/cgi-bin/cgi-gw.exe?action=capt&fooid=\2
balance leastconn server server8080 10.10.14.127:8080 check server server8081 10.10.14.127:8081 check backend apache_foothumb reqirep ^([^\ ]*)\ /foothumb/(.*) \1\
/cgi-bin/cgi-gw.exe?action=thumbres&fooid=\2
balance leastconn server server8080 10.10.14.127:8080 check server server8081 10.10.14.127:8081 check backend apache_featured reqirep ^([^\ ]*)\ /featured/foothumbnew/(.*) \1\
/cgi-bin/cgi-gw.exe?action=thumbreshigh&fooid=\2
balance leastconn server server8080 10.10.14.127:8080 check server server8081 10.10.14.127:8081 check
Received on 2010/12/15 23:32

This archive was generated by hypermail 2.2.0 : 2010/12/15 23:45 CET