You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by ji...@apache.org on 2002/02/27 16:49:01 UTC
cvs commit: httpd-2.0/modules/proxy mod_proxy.c mod_proxy.h
jim 02/02/27 07:49:01
Modified: . CHANGES
modules/proxy mod_proxy.c mod_proxy.h
Log:
Add the ProxyRemoteMatch directive to the mod_proxy
code. Doccos to be done soon
Revision Changes Path
1.612 +4 -0 httpd-2.0/CHANGES
Index: CHANGES
===================================================================
RCS file: /home/cvs/httpd-2.0/CHANGES,v
retrieving revision 1.611
retrieving revision 1.612
diff -u -r1.611 -r1.612
--- CHANGES 27 Feb 2002 04:00:47 -0000 1.611
+++ CHANGES 27 Feb 2002 15:49:00 -0000 1.612
@@ -1,5 +1,9 @@
Changes with Apache 2.0.33-dev
+ *) New Directive for mod_proxy: ProxyRemoteMatch. This provides
+ regex pattern matching for the determination of which requests
+ to use the remote proxy for. [Jim Jagielski]
+
*) Fix CustomLog bytes-sent with HTTP 0.9. [Justin Erenkrantz]
*) Prevent Apache from ignoring SIGHUP due to some lingering 1.3
1.72 +38 -7 httpd-2.0/modules/proxy/mod_proxy.c
Index: mod_proxy.c
===================================================================
RCS file: /home/cvs/httpd-2.0/modules/proxy/mod_proxy.c,v
retrieving revision 1.71
retrieving revision 1.72
diff -u -r1.71 -r1.72
--- mod_proxy.c 12 Feb 2002 17:41:35 -0000 1.71
+++ mod_proxy.c 27 Feb 2002 15:49:01 -0000 1.72
@@ -431,6 +431,7 @@
for (i = 0; i < proxies->nelts; i++) {
p2 = ap_strchr_c(ents[i].scheme, ':'); /* is it a partial URL? */
if (strcmp(ents[i].scheme, "*") == 0 ||
+ (ents[i].use_regex && ap_regexec(ents[i].regexp, url, 0,NULL, 0)) ||
(p2 == NULL && strcasecmp(scheme, ents[i].scheme) == 0) ||
(p2 != NULL &&
strncasecmp(url, ents[i].scheme, strlen(ents[i].scheme)) == 0)) {
@@ -548,7 +549,7 @@
static const char *
- add_proxy(cmd_parms *cmd, void *dummy, const char *f1, const char *r1)
+ add_proxy(cmd_parms *cmd, void *dummy, const char *f1, const char *r1, int regex)
{
server_rec *s = cmd->server;
proxy_server_conf *conf =
@@ -556,6 +557,7 @@
struct proxy_remote *new;
char *p, *q;
char *r, *f, *scheme;
+ regex_t *reg = NULL;
int port;
r = apr_pstrdup(cmd->pool, r1);
@@ -563,22 +565,35 @@
f = apr_pstrdup(cmd->pool, f1);
p = strchr(r, ':');
if (p == NULL || p[1] != '/' || p[2] != '/' || p[3] == '\0') {
- return "ProxyRemote: Bad syntax for a remote proxy server";
+ if (regex)
+ return "ProxyRemoteMatch: Bad syntax for a remote proxy server";
+ else
+ return "ProxyRemote: Bad syntax for a remote proxy server";
}
else {
scheme[p-r] = 0;
}
q = strchr(p + 3, ':');
if (q != NULL) {
- if (sscanf(q + 1, "%u", &port) != 1 || port > 65535)
- return "ProxyRemote: Bad syntax for a remote proxy server (bad port number)";
+ if (sscanf(q + 1, "%u", &port) != 1 || port > 65535) {
+ if (regex)
+ return "ProxyRemoteMatch: Bad syntax for a remote proxy server (bad port number)";
+ else
+ return "ProxyRemote: Bad syntax for a remote proxy server (bad port number)";
+ }
*q = '\0';
}
else
port = -1;
*p = '\0';
- if (strchr(f, ':') == NULL)
- ap_str_tolower(f); /* lowercase scheme */
+ if (regex) {
+ reg = ap_pregcomp(cmd->pool, f, REG_EXTENDED);
+ if (!reg)
+ return "Regular expression for ProxyRemoteMatch could not be compiled.";
+ }
+ else
+ if (strchr(f, ':') == NULL)
+ ap_str_tolower(f); /* lowercase scheme */
ap_str_tolower(p + 3); /* lowercase hostname */
if (port == -1) {
@@ -590,10 +605,24 @@
new->protocol = r;
new->hostname = p + 3;
new->port = port;
+ new->regexp = reg;
+ new->use_regex = regex;
return NULL;
}
static const char *
+ add_proxy_noregex(cmd_parms *cmd, void *dummy, const char *f1, const char *r1)
+{
+ return add_proxy(cmd, dummy, f1, r1, 0);
+}
+
+static const char *
+ add_proxy_regex(cmd_parms *cmd, void *dummy, const char *f1, const char *r1)
+{
+ return add_proxy(cmd, dummy, f1, r1, 1);
+}
+
+static const char *
add_pass(cmd_parms *cmd, void *dummy, const char *f, const char *r)
{
server_rec *s = cmd->server;
@@ -963,8 +992,10 @@
"location, in regular expression syntax"),
AP_INIT_FLAG("ProxyRequests", set_proxy_req, NULL, RSRC_CONF,
"on if the true proxy requests should be accepted"),
- AP_INIT_TAKE2("ProxyRemote", add_proxy, NULL, RSRC_CONF,
+ AP_INIT_TAKE2("ProxyRemote", add_proxy_noregex, NULL, RSRC_CONF,
"a scheme, partial URL or '*' and a proxy server"),
+ AP_INIT_TAKE2("ProxyRemoteMatch", add_proxy_regex, NULL, RSRC_CONF,
+ "a regex pattern and a proxy server"),
AP_INIT_TAKE12("ProxyPass", add_pass, NULL, RSRC_CONF|ACCESS_CONF,
"a virtual path and a URL"),
AP_INIT_TAKE12("ProxyPassReverse", add_pass_reverse, NULL, RSRC_CONF|ACCESS_CONF,
1.73 +2 -0 httpd-2.0/modules/proxy/mod_proxy.h
Index: mod_proxy.h
===================================================================
RCS file: /home/cvs/httpd-2.0/modules/proxy/mod_proxy.h,v
retrieving revision 1.72
retrieving revision 1.73
diff -u -r1.72 -r1.73
--- mod_proxy.h 21 Feb 2002 11:42:03 -0000 1.72
+++ mod_proxy.h 27 Feb 2002 15:49:01 -0000 1.73
@@ -136,6 +136,8 @@
const char *protocol; /* the scheme used to talk to this proxy */
const char *hostname; /* the hostname of this proxy */
apr_port_t port; /* the port for this proxy */
+ regex_t *regexp; /* compiled regex (if any) for the remote */
+ int use_regex; /* simple boolean. True if we have a regex pattern */
};
struct proxy_alias {