Skip to content

Commit 49ad0be

Browse files
committed
* 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
1 parent 7258e81 commit 49ad0be

6 files changed

Lines changed: 32 additions & 4 deletions

File tree

CHANGES

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ Changes with Apache 2.2.10
55
mod_proxy_ftp: Prevent XSS attacks when using wildcards in the path of
66
the FTP URL. Discovered by Marc Bevand of Rapid7. [Ruediger Pluem]
77

8+
*) mod_proxy: Add 'scolonpathdelim' parameter to allow for ';' to also be
9+
used as a session path separator/delim PR 45158. [Jim Jagielski]
10+
811
*) mod_charset_lite: Avoid dropping error responses by handling meta buckets
912
correctly. PR 45687 [Dan Poirier <poirier pobox.com>]
1013

docs/manual/mod/mod_proxy.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -838,6 +838,13 @@ expressions</description>
838838
and url encoded id (like servlet containers) use | to to separate them.
839839
The first part is for the cookie the second for the path.
840840
</td></tr>
841+
<tr><td>scolonpathdelim</td>
842+
<td>Off</td>
843+
<td>If set to <code>On</code> the semi-colon character ';' will be
844+
used as an additional sticky session path deliminator/separator. This
845+
is mainly used to emulate mod_jk's behavior when dealing with paths such
846+
as <code>JSESSIONID=6736bcf34;foo=aabfa</code>
847+
</td></tr>
841848
<tr><td>timeout</td>
842849
<td>0</td>
843850
<td>Balancer timeout in seconds. If set this will be the maximum time

include/ap_mmn.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@
130130
* introduce proxy_req_conf.
131131
* 20051115.16(2.2.9) Add conn_timeout and conn_timeout_set to
132132
* proxy_worker struct.
133+
* 20051115.17(2.2.10) Add scolonsep to proxy_balancer
133134
*
134135
*/
135136

@@ -138,7 +139,7 @@
138139
#ifndef MODULE_MAGIC_NUMBER_MAJOR
139140
#define MODULE_MAGIC_NUMBER_MAJOR 20051115
140141
#endif
141-
#define MODULE_MAGIC_NUMBER_MINOR 16 /* 0...n */
142+
#define MODULE_MAGIC_NUMBER_MINOR 17 /* 0...n */
142143

143144
/**
144145
* Determine if the server's current MODULE_MAGIC_NUMBER is at least a

modules/proxy/mod_proxy.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,18 @@ static const char *set_balancer_param(proxy_server_conf *conf,
348348
}
349349
return "unknown lbmethod";
350350
}
351+
else if (!strcasecmp(key, "scolonpathdelim")) {
352+
/* If set to 'on' then ';' will also be
353+
* used as a session path separator/delim (ala
354+
* mod_jk)
355+
*/
356+
if (!strcasecmp(val, "on"))
357+
balancer->scolonsep = 1;
358+
else if (!strcasecmp(val, "off"))
359+
balancer->scolonsep = 0;
360+
else
361+
return "scolonpathdelim must be On|Off";
362+
}
351363
else {
352364
return "unknown Balancer parameter";
353365
}

modules/proxy/mod_proxy.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,7 @@ struct proxy_balancer {
384384
apr_thread_mutex_t *mutex; /* Thread lock for updating lb params */
385385
#endif
386386
void *context; /* general purpose storage */
387+
int scolonsep; /* true if ';' seps sticky session paths */
387388
};
388389

389390
struct proxy_balancer_method {

modules/proxy/mod_proxy_balancer.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,14 @@ static int init_balancer_members(proxy_server_conf *conf, server_rec *s,
127127
* Something like 'JSESSIONID=12345...N'
128128
*/
129129
static char *get_path_param(apr_pool_t *pool, char *url,
130-
const char *name)
130+
const char *name, int scolon_sep)
131131
{
132132
char *path = NULL;
133+
char *pathdelims = "?&";
133134

135+
if (scolon_sep) {
136+
pathdelims = ";?&";
137+
}
134138
for (path = strstr(url, name); path; path = strstr(path + 1, name)) {
135139
path += strlen(name);
136140
if (*path == '=') {
@@ -140,7 +144,7 @@ static char *get_path_param(apr_pool_t *pool, char *url,
140144
++path;
141145
if (strlen(path)) {
142146
char *q;
143-
path = apr_strtok(apr_pstrdup(pool, path), "?&", &q);
147+
path = apr_strtok(apr_pstrdup(pool, path), pathdelims, &q);
144148
return path;
145149
}
146150
}
@@ -268,7 +272,7 @@ static proxy_worker *find_session_route(proxy_balancer *balancer,
268272

269273
/* Try to find the sticky route inside url */
270274
*sticky_used = sticky_path;
271-
*route = get_path_param(r->pool, *url, sticky_path);
275+
*route = get_path_param(r->pool, *url, sticky_path, balancer->scolonsep);
272276
if (!*route) {
273277
*route = get_cookie_param(r, sticky);
274278
*sticky_used = sticky;

0 commit comments

Comments
 (0)