From: Jim Jagielski Date: Wed, 17 Sep 2008 14:29:14 +0000 (+0000) Subject: * mod_proxy_balancer: Allow for treatment of ';' char as a session X-Git-Tag: 2.2.10~35 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=de3d2ba1cf0a895ef957cbaf5945f59436e834bc;p=thirdparty%2Fapache%2Fhttpd.git * mod_proxy_balancer: Allow for treatment of ';' char as a session deliminator/separator, ala mod_jk. PR: 45158 Trunk version of patch: http://svn.apache.org/viewvc?rev=686809&view=rev http://svn.apache.org/viewvc?rev=687754&view=rev Backport version for 2.2.x of patch: http://people.apache.org/~jim/patches/scolon-proxy.patch.txt +1: jim, rpluem, jerenkrantz git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.2.x@696319 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/CHANGES b/CHANGES index b5d3d0d5c33..1889ae0402b 100644 --- a/CHANGES +++ b/CHANGES @@ -5,6 +5,9 @@ Changes with Apache 2.2.10 mod_proxy_ftp: Prevent XSS attacks when using wildcards in the path of the FTP URL. Discovered by Marc Bevand of Rapid7. [Ruediger Pluem] + *) mod_proxy: Add 'scolonpathdelim' parameter to allow for ';' to also be + used as a session path separator/delim PR 45158. [Jim Jagielski] + *) mod_charset_lite: Avoid dropping error responses by handling meta buckets correctly. PR 45687 [Dan Poirier ] diff --git a/docs/manual/mod/mod_proxy.xml b/docs/manual/mod/mod_proxy.xml index bebe75e275b..2b786e3d113 100644 --- a/docs/manual/mod/mod_proxy.xml +++ b/docs/manual/mod/mod_proxy.xml @@ -838,6 +838,13 @@ expressions and url encoded id (like servlet containers) use | to to separate them. The first part is for the cookie the second for the path. + scolonpathdelim + Off + If set to On the semi-colon character ';' will be + used as an additional sticky session path deliminator/separator. This + is mainly used to emulate mod_jk's behavior when dealing with paths such + as JSESSIONID=6736bcf34;foo=aabfa + timeout 0 Balancer timeout in seconds. If set this will be the maximum time diff --git a/include/ap_mmn.h b/include/ap_mmn.h index 656189df53d..85408f576ad 100644 --- a/include/ap_mmn.h +++ b/include/ap_mmn.h @@ -130,6 +130,7 @@ * introduce proxy_req_conf. * 20051115.16(2.2.9) Add conn_timeout and conn_timeout_set to * proxy_worker struct. + * 20051115.17(2.2.10) Add scolonsep to proxy_balancer * */ @@ -138,7 +139,7 @@ #ifndef MODULE_MAGIC_NUMBER_MAJOR #define MODULE_MAGIC_NUMBER_MAJOR 20051115 #endif -#define MODULE_MAGIC_NUMBER_MINOR 16 /* 0...n */ +#define MODULE_MAGIC_NUMBER_MINOR 17 /* 0...n */ /** * Determine if the server's current MODULE_MAGIC_NUMBER is at least a diff --git a/modules/proxy/mod_proxy.c b/modules/proxy/mod_proxy.c index a6c50242c45..15e7e8ef80a 100644 --- a/modules/proxy/mod_proxy.c +++ b/modules/proxy/mod_proxy.c @@ -348,6 +348,18 @@ static const char *set_balancer_param(proxy_server_conf *conf, } return "unknown lbmethod"; } + else if (!strcasecmp(key, "scolonpathdelim")) { + /* If set to 'on' then ';' will also be + * used as a session path separator/delim (ala + * mod_jk) + */ + if (!strcasecmp(val, "on")) + balancer->scolonsep = 1; + else if (!strcasecmp(val, "off")) + balancer->scolonsep = 0; + else + return "scolonpathdelim must be On|Off"; + } else { return "unknown Balancer parameter"; } diff --git a/modules/proxy/mod_proxy.h b/modules/proxy/mod_proxy.h index 2381515c5dd..55f64598904 100644 --- a/modules/proxy/mod_proxy.h +++ b/modules/proxy/mod_proxy.h @@ -384,6 +384,7 @@ struct proxy_balancer { apr_thread_mutex_t *mutex; /* Thread lock for updating lb params */ #endif void *context; /* general purpose storage */ + int scolonsep; /* true if ';' seps sticky session paths */ }; struct proxy_balancer_method { diff --git a/modules/proxy/mod_proxy_balancer.c b/modules/proxy/mod_proxy_balancer.c index e4b2d9a47d6..7b6612639fa 100644 --- a/modules/proxy/mod_proxy_balancer.c +++ b/modules/proxy/mod_proxy_balancer.c @@ -127,10 +127,14 @@ static int init_balancer_members(proxy_server_conf *conf, server_rec *s, * Something like 'JSESSIONID=12345...N' */ static char *get_path_param(apr_pool_t *pool, char *url, - const char *name) + const char *name, int scolon_sep) { char *path = NULL; + char *pathdelims = "?&"; + if (scolon_sep) { + pathdelims = ";?&"; + } for (path = strstr(url, name); path; path = strstr(path + 1, name)) { path += strlen(name); if (*path == '=') { @@ -140,7 +144,7 @@ static char *get_path_param(apr_pool_t *pool, char *url, ++path; if (strlen(path)) { char *q; - path = apr_strtok(apr_pstrdup(pool, path), "?&", &q); + path = apr_strtok(apr_pstrdup(pool, path), pathdelims, &q); return path; } } @@ -268,7 +272,7 @@ static proxy_worker *find_session_route(proxy_balancer *balancer, /* Try to find the sticky route inside url */ *sticky_used = sticky_path; - *route = get_path_param(r->pool, *url, sticky_path); + *route = get_path_param(r->pool, *url, sticky_path, balancer->scolonsep); if (!*route) { *route = get_cookie_param(r, sticky); *sticky_used = sticky;