Re: Multiple reqirep statements in frontends and backends
Le mercredi 15 décembre 2010 23:32:23, Shawn Heisey a écrit : > 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. That should. > 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? This is probably due to a non trivial misconfiguration. > 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. You mean one server list for several backends ? Currently, no. This configuration should work (fixed the acl and merged all the reqirep in the frontend) : 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 reqirep ^([^\ ]*)\ /fooh/(.*) \1\ /cgi-bin/cgi- gw.exe?action=autodetails&fooid=\2 if bot fooh reqirep ^([^\ ]*)\ /foo/(.*) \1\ /cgi-bin/cgi- gw.exe?action=webres&fooid=\2 if foo reqirep ^([^\ ]*)\ /fooc/(.*) \1\ /cgi-bin/cgi- gw.exe?action=capt&fooid=\2 if fooc reqirep ^([^\ ]*)\ /foothumb/(.*) \1\ /cgi-bin/cgi- gw.exe?action=thumbres&fooid=\2 if foothumb reqirep ^([^\ ]*)\ /featured/foothumbnew/(.*) \1\ /cgi-bin/cgi- gw.exe?action=thumbreshigh&fooid=\2 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 -- Cyril Bonté
Re: Multiple reqirep statements in frontends and backends
On 12/15/2010 7:50 PM, Cyril Bonté wrote: This configuration should work (fixed the acl and merged all the reqirep in the frontend) : The things that match /foo* can't use the tomcat backend, they have to use the apache backend. Everything that doesn't match an ACL uses the tomcat backend, which is not really tomcat, it's still apache - but apache sends it through to tomcat, thus the name. The /foo* paths are sent to the CGI, hosted by apache. If we can make it work, I do plan eventually to put the actual tomcat server ports in the tomcat backend. Apologies for presenting a moving configuration target. It has now moved into production and the config is different in minor ways. It now has two servers, not just one. I've put the sanitized config up on a webserver so you can see it without your email client making changes to it. http://www.elyograg.org/haproxycfg.txt
Re: Multiple reqirep statements in frontends and backends
On 12/15/2010 9:20 PM, Shawn Heisey wrote: On 12/15/2010 7:50 PM, Cyril Bonté wrote: This configuration should work (fixed the acl and merged all the reqirep in the frontend) : The things that match /foo* can't use the tomcat backend, they have to use the apache backend. Everything that doesn't match an ACL uses the tomcat backend, which is not really tomcat, it's still apache - but apache sends it through to tomcat, thus the name. The /foo* paths are sent to the CGI, hosted by apache. If we can make it work, I do plan eventually to put the actual tomcat server ports in the tomcat backend. Apologies for presenting a moving configuration target. It has now moved into production and the config is different in minor ways. It now has two servers, not just one. I've put the sanitized config up on a webserver so you can see it without your email client making changes to it. http://www.elyograg.org/haproxycfg.txt Perhaps what doesn't work in my first attempt is having more than one thing happen if an ACL matches. To put everything into the frontend, I need to use a config like this, to have it both rewrite the request and send it to a nondefault backend: reqirep ^([^\ ]*)\ /fooc/(.*) \1\ /cgi-bin/cgi-gw.exe?action=capt&fooid=\2if fooc use_backend apacheif fooc I'm guessing that it works like a Cisco access-list - the first entry that matches determines the outcome, the rest of the entries are ignored. If I'm right, then it would probably work if I put all the reqirep statements in the backend, where they wouldn't need acl conditions. Thanks, Shawn
Re: Multiple reqirep statements in frontends and backends
Le jeudi 16 décembre 2010 06:21:08, Shawn Heisey a écrit : > On 12/15/2010 9:20 PM, Shawn Heisey wrote: > > On 12/15/2010 7:50 PM, Cyril Bonté wrote: > >> This configuration > >> should work (fixed the acl and merged all the reqirep in the > > > >> frontend) : > > The things that match /foo* can't use the tomcat backend, they have to > > use the apache backend. Everything that doesn't match an ACL uses the > > tomcat backend, which is not really tomcat, it's still apache - but > > apache sends it through to tomcat, thus the name. The /foo* paths are > > sent to the CGI, hosted by apache. If we can make it work, I do plan > > eventually to put the actual tomcat server ports in the tomcat backend. Yes, this is how this configuration works. Example : Incoming request is : GET /fooc/bar HTTP/1.1 => APPLYING reqirep ^([^\ ]*)\ /fooc/(.*) \1\ /cgi-bin/cgi- gw.exe?action=capt&fooid=\2 The request becomes : GET /cgi-bin/cgi-gw.exe?action=capt&fooid=bar HTTP/1.1 It won't match the 'fooc' acl anymore but the 'cgi' one will. And you've got : use_backend apache if cgi which sends the request to the apache backend. > Perhaps what doesn't work in my first attempt is having more than one > thing happen if an ACL matches. To put everything into the frontend, I > need to use a config like this, to have it both rewrite the request and > send it to a nondefault backend: > > reqirep ^([^\ ]*)\ /fooc/(.*) \1\ > /cgi-bin/cgi-gw.exe?action=capt&fooid=\2if fooc > use_backend apacheif fooc > > I'm guessing that it works like a Cisco access-list - the first entry > that matches determines the outcome, the rest of the entries are > ignored. If I'm right, then it would probably work if I put all the > reqirep statements in the backend, where they wouldn't need acl conditions. ACL are re-evaluated each time a condition is met. This is why "use_backend apache if fooc" can't match after "reqirep" (I missed these lines in your first example, sorry). -- Cyril Bonté
Re: Multiple reqirep statements in frontends and backends
On 12/15/2010 11:30 PM, Cyril Bonté wrote: Yes, this is how this configuration works. Example : Incoming request is : GET /fooc/bar HTTP/1.1 => APPLYING reqirep ^([^\ ]*)\ /fooc/(.*) \1\ /cgi-bin/cgi- gw.exe?action=capt&fooid=\2 The request becomes : GET /cgi-bin/cgi-gw.exe?action=capt&fooid=bar HTTP/1.1 It won't match the 'fooc' acl anymore but the 'cgi' one will. And you've got : use_backend apache if cgi which sends the request to the apache backend. That's very cool! Complete re-evaluation of all the components after every step is extremely powerful, and unexpected. This program never ceases to impress me. Thank you for your awesome work. Thanks to this config, one of our major clients is happy to have a reliable service. We were starting to think we'd have to rewrite the entire system for Linux to make it stable. If this re-evaluation behavior is in the documentation, and it very likely is, could you point out which section in the 1.4 docs covers it? I think management will want to keep the separate backends for the stats information, so what I'll be doing is eventually upgrading to 1.5-dev and utilizing the include syntax so that I don't have to worry about the server list being typed wrong in one of the backends. Will that functionality work in the way I want it to? Thanks, Shawn