From: Ruediger Pluem Date: Wed, 20 Jul 2016 18:32:14 +0000 (+0000) Subject: * Prevent redirect loops between workers within a balancer by limiting the X-Git-Tag: 2.5.0-alpha~1384 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=af9775ba478482f97789aa977dd9ced553495000;p=thirdparty%2Fapache%2Fhttpd.git * Prevent redirect loops between workers within a balancer by limiting the number of redirects to the number balancer members. PR: 59864 git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1753594 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/CHANGES b/CHANGES index 598e6302cf5..4794d465a3d 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,10 @@ -*- coding: utf-8 -*- Changes with Apache 2.5.0 + *) mod_proxy_balancer: Prevent redirect loops between workers within a + balancer by limiting the number of redirects to the number balancer + members. PR 59864 [Ruediger Pluem] + *) mod_proxy: Correctly consider error response codes by the backend when processing failonstatus. PR 59869 [Ruediger Pluem] diff --git a/modules/proxy/mod_proxy_balancer.c b/modules/proxy/mod_proxy_balancer.c index cbd62aed4d3..994208c17e3 100644 --- a/modules/proxy/mod_proxy_balancer.c +++ b/modules/proxy/mod_proxy_balancer.c @@ -212,7 +212,8 @@ static char *get_cookie_param(request_rec *r, const char *name) /* Find the worker that has the 'route' defined */ static proxy_worker *find_route_worker(proxy_balancer *balancer, - const char *route, request_rec *r) + const char *route, request_rec *r, + int recursion) { int i; int checking_standby; @@ -249,10 +250,15 @@ static proxy_worker *find_route_worker(proxy_balancer *balancer, * This enables to safely remove the member from the * balancer. Of course you will need some kind of * session replication between those two remote. + * Also check that we haven't gone thru all the + * balancer members by means of redirects. + * This should avoid redirect cycles. */ - if (*worker->s->redirect) { + if ((*worker->s->redirect) + && (recursion < balancer->workers->nelts)) { proxy_worker *rworker = NULL; - rworker = find_route_worker(balancer, worker->s->redirect, r); + rworker = find_route_worker(balancer, worker->s->redirect, + r, recursion + 1); /* Check if the redirect worker is usable */ if (rworker && !PROXY_WORKER_IS_USABLE(rworker)) { /* @@ -315,7 +321,7 @@ static proxy_worker *find_session_route(proxy_balancer *balancer, /* We have a route in path or in cookie * Find the worker that has this route defined. */ - worker = find_route_worker(balancer, *route, r); + worker = find_route_worker(balancer, *route, r, 1); if (worker && strcmp(*route, worker->s->route)) { /* * Notice that the route of the worker chosen is different from