mirror of
https://github.com/apache/httpd.git
synced 2025-08-08 15:02:10 +03:00
Add the ProxyRemoteMatch directive to the mod_proxy
code. Doccos to be done soon git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@93597 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
4
CHANGES
4
CHANGES
@@ -1,5 +1,9 @@
|
|||||||
Changes with Apache 2.0.33-dev
|
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]
|
*) Fix CustomLog bytes-sent with HTTP 0.9. [Justin Erenkrantz]
|
||||||
|
|
||||||
*) Prevent Apache from ignoring SIGHUP due to some lingering 1.3
|
*) Prevent Apache from ignoring SIGHUP due to some lingering 1.3
|
||||||
|
@@ -431,6 +431,7 @@ static int proxy_handler(request_rec *r)
|
|||||||
for (i = 0; i < proxies->nelts; i++) {
|
for (i = 0; i < proxies->nelts; i++) {
|
||||||
p2 = ap_strchr_c(ents[i].scheme, ':'); /* is it a partial URL? */
|
p2 = ap_strchr_c(ents[i].scheme, ':'); /* is it a partial URL? */
|
||||||
if (strcmp(ents[i].scheme, "*") == 0 ||
|
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 && strcasecmp(scheme, ents[i].scheme) == 0) ||
|
||||||
(p2 != NULL &&
|
(p2 != NULL &&
|
||||||
strncasecmp(url, ents[i].scheme, strlen(ents[i].scheme)) == 0)) {
|
strncasecmp(url, ents[i].scheme, strlen(ents[i].scheme)) == 0)) {
|
||||||
@@ -548,7 +549,7 @@ static void *merge_proxy_dir_config(apr_pool_t *p, void *basev, void *addv)
|
|||||||
|
|
||||||
|
|
||||||
static const char *
|
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;
|
server_rec *s = cmd->server;
|
||||||
proxy_server_conf *conf =
|
proxy_server_conf *conf =
|
||||||
@@ -556,6 +557,7 @@ static const char *
|
|||||||
struct proxy_remote *new;
|
struct proxy_remote *new;
|
||||||
char *p, *q;
|
char *p, *q;
|
||||||
char *r, *f, *scheme;
|
char *r, *f, *scheme;
|
||||||
|
regex_t *reg = NULL;
|
||||||
int port;
|
int port;
|
||||||
|
|
||||||
r = apr_pstrdup(cmd->pool, r1);
|
r = apr_pstrdup(cmd->pool, r1);
|
||||||
@@ -563,6 +565,9 @@ static const char *
|
|||||||
f = apr_pstrdup(cmd->pool, f1);
|
f = apr_pstrdup(cmd->pool, f1);
|
||||||
p = strchr(r, ':');
|
p = strchr(r, ':');
|
||||||
if (p == NULL || p[1] != '/' || p[2] != '/' || p[3] == '\0') {
|
if (p == NULL || p[1] != '/' || p[2] != '/' || p[3] == '\0') {
|
||||||
|
if (regex)
|
||||||
|
return "ProxyRemoteMatch: Bad syntax for a remote proxy server";
|
||||||
|
else
|
||||||
return "ProxyRemote: Bad syntax for a remote proxy server";
|
return "ProxyRemote: Bad syntax for a remote proxy server";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -570,13 +575,23 @@ static const char *
|
|||||||
}
|
}
|
||||||
q = strchr(p + 3, ':');
|
q = strchr(p + 3, ':');
|
||||||
if (q != NULL) {
|
if (q != NULL) {
|
||||||
if (sscanf(q + 1, "%u", &port) != 1 || port > 65535)
|
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)";
|
return "ProxyRemote: Bad syntax for a remote proxy server (bad port number)";
|
||||||
|
}
|
||||||
*q = '\0';
|
*q = '\0';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
port = -1;
|
port = -1;
|
||||||
*p = '\0';
|
*p = '\0';
|
||||||
|
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)
|
if (strchr(f, ':') == NULL)
|
||||||
ap_str_tolower(f); /* lowercase scheme */
|
ap_str_tolower(f); /* lowercase scheme */
|
||||||
ap_str_tolower(p + 3); /* lowercase hostname */
|
ap_str_tolower(p + 3); /* lowercase hostname */
|
||||||
@@ -590,9 +605,23 @@ static const char *
|
|||||||
new->protocol = r;
|
new->protocol = r;
|
||||||
new->hostname = p + 3;
|
new->hostname = p + 3;
|
||||||
new->port = port;
|
new->port = port;
|
||||||
|
new->regexp = reg;
|
||||||
|
new->use_regex = regex;
|
||||||
return NULL;
|
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 *
|
static const char *
|
||||||
add_pass(cmd_parms *cmd, void *dummy, const char *f, const char *r)
|
add_pass(cmd_parms *cmd, void *dummy, const char *f, const char *r)
|
||||||
{
|
{
|
||||||
@@ -963,8 +992,10 @@ static const command_rec proxy_cmds[] =
|
|||||||
"location, in regular expression syntax"),
|
"location, in regular expression syntax"),
|
||||||
AP_INIT_FLAG("ProxyRequests", set_proxy_req, NULL, RSRC_CONF,
|
AP_INIT_FLAG("ProxyRequests", set_proxy_req, NULL, RSRC_CONF,
|
||||||
"on if the true proxy requests should be accepted"),
|
"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"),
|
"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,
|
AP_INIT_TAKE12("ProxyPass", add_pass, NULL, RSRC_CONF|ACCESS_CONF,
|
||||||
"a virtual path and a URL"),
|
"a virtual path and a URL"),
|
||||||
AP_INIT_TAKE12("ProxyPassReverse", add_pass_reverse, NULL, RSRC_CONF|ACCESS_CONF,
|
AP_INIT_TAKE12("ProxyPassReverse", add_pass_reverse, NULL, RSRC_CONF|ACCESS_CONF,
|
||||||
|
@@ -136,6 +136,8 @@ struct proxy_remote {
|
|||||||
const char *protocol; /* the scheme used to talk to this proxy */
|
const char *protocol; /* the scheme used to talk to this proxy */
|
||||||
const char *hostname; /* the hostname of this proxy */
|
const char *hostname; /* the hostname of this proxy */
|
||||||
apr_port_t port; /* the port for 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 {
|
struct proxy_alias {
|
||||||
|
Reference in New Issue
Block a user