Lines 1187-1193
static int proxy_handler(request_rec *r)
Link Here
|
1187 |
access_status = proxy_run_scheme_handler(r, worker, |
1187 |
access_status = proxy_run_scheme_handler(r, worker, |
1188 |
conf, url, |
1188 |
conf, url, |
1189 |
ents[i].hostname, |
1189 |
ents[i].hostname, |
1190 |
ents[i].port); |
1190 |
ents[i].port, |
|
|
1191 |
ents[i].auth); |
1191 |
|
1192 |
|
1192 |
/* Did the scheme handler process the request? */ |
1193 |
/* Did the scheme handler process the request? */ |
1193 |
if (access_status != DECLINED) { |
1194 |
if (access_status != DECLINED) { |
Lines 1239-1245
static int proxy_handler(request_rec *r)
Link Here
|
1239 |
scheme, attempts); |
1240 |
scheme, attempts); |
1240 |
AP_PROXY_RUN(r, worker, conf, url, attempts); |
1241 |
AP_PROXY_RUN(r, worker, conf, url, attempts); |
1241 |
access_status = proxy_run_scheme_handler(r, worker, conf, |
1242 |
access_status = proxy_run_scheme_handler(r, worker, conf, |
1242 |
url, NULL, 0); |
1243 |
url, NULL, 0, NULL); |
1243 |
if (access_status == OK |
1244 |
if (access_status == OK |
1244 |
|| apr_table_get(r->notes, "proxy-error-override")) |
1245 |
|| apr_table_get(r->notes, "proxy-error-override")) |
1245 |
break; |
1246 |
break; |
Lines 1605-1611
static const char *
Link Here
|
1605 |
proxy_server_conf *conf = |
1606 |
proxy_server_conf *conf = |
1606 |
(proxy_server_conf *) ap_get_module_config(s->module_config, &proxy_module); |
1607 |
(proxy_server_conf *) ap_get_module_config(s->module_config, &proxy_module); |
1607 |
struct proxy_remote *new; |
1608 |
struct proxy_remote *new; |
1608 |
char *p, *q; |
1609 |
char *p, *q, *a; |
1609 |
char *r, *f, *scheme; |
1610 |
char *r, *f, *scheme; |
1610 |
ap_regex_t *reg = NULL; |
1611 |
ap_regex_t *reg = NULL; |
1611 |
int port; |
1612 |
int port; |
Lines 1613-1618
static const char *
Link Here
|
1613 |
r = apr_pstrdup(cmd->pool, r1); |
1614 |
r = apr_pstrdup(cmd->pool, r1); |
1614 |
scheme = apr_pstrdup(cmd->pool, r1); |
1615 |
scheme = apr_pstrdup(cmd->pool, r1); |
1615 |
f = apr_pstrdup(cmd->pool, f1); |
1616 |
f = apr_pstrdup(cmd->pool, f1); |
|
|
1617 |
/* separate different items from remote proxy server configuration |
1618 |
* r = <scheme>://[<auth>@]<host>[:<port>] |
1619 |
*/ |
1620 |
/* separate scheme (must) */ |
1616 |
p = strchr(r, ':'); |
1621 |
p = strchr(r, ':'); |
1617 |
if (p == NULL || p[1] != '/' || p[2] != '/' || p[3] == '\0') { |
1622 |
if (p == NULL || p[1] != '/' || p[2] != '/' || p[3] == '\0') { |
1618 |
if (regex) |
1623 |
if (regex) |
Lines 1621-1629
static const char *
Link Here
|
1621 |
return "ProxyRemote: Bad syntax for a remote proxy server"; |
1626 |
return "ProxyRemote: Bad syntax for a remote proxy server"; |
1622 |
} |
1627 |
} |
1623 |
else { |
1628 |
else { |
1624 |
scheme[p-r] = 0; |
1629 |
scheme[p-r] = '\0'; |
|
|
1630 |
} |
1631 |
*p = '\0'; /* terminate r (scheme) */ |
1632 |
p+=3; |
1633 |
/* separate authentication string (optional, default = NULL) */ |
1634 |
q = strchr(p, '@'); |
1635 |
if (q != NULL) { |
1636 |
*q = '\0'; |
1637 |
/* missing: syntax check of the auth string |
1638 |
* but do we really need this? |
1639 |
*/ |
1640 |
a = ap_pbase64encode(cmd->pool, p); |
1641 |
p = q; |
1642 |
p+=1; |
1643 |
} |
1644 |
else { |
1645 |
a = NULL; |
1625 |
} |
1646 |
} |
1626 |
q = strchr(p + 3, ':'); |
1647 |
/* separate port (optional, default = default port of scheme) */ |
|
|
1648 |
q = strchr(p, ':'); |
1627 |
if (q != NULL) { |
1649 |
if (q != NULL) { |
1628 |
if (sscanf(q + 1, "%u", &port) != 1 || port > 65535) { |
1650 |
if (sscanf(q + 1, "%u", &port) != 1 || port > 65535) { |
1629 |
if (regex) |
1651 |
if (regex) |
Lines 1633-1650
static const char *
Link Here
|
1633 |
} |
1655 |
} |
1634 |
*q = '\0'; |
1656 |
*q = '\0'; |
1635 |
} |
1657 |
} |
1636 |
else |
1658 |
else { |
1637 |
port = -1; |
1659 |
port = -1; |
1638 |
*p = '\0'; |
1660 |
} |
|
|
1661 |
|
1639 |
if (regex) { |
1662 |
if (regex) { |
1640 |
reg = ap_pregcomp(cmd->pool, f, AP_REG_EXTENDED); |
1663 |
reg = ap_pregcomp(cmd->pool, f, AP_REG_EXTENDED); |
1641 |
if (!reg) |
1664 |
if (!reg) |
1642 |
return "Regular expression for ProxyRemoteMatch could not be compiled."; |
1665 |
return "Regular expression for ProxyRemoteMatch could not be compiled."; |
1643 |
} |
1666 |
} |
1644 |
else |
1667 |
else |
1645 |
if (strchr(f, ':') == NULL) |
1668 |
if (strchr(f, ':') == NULL) { |
1646 |
ap_str_tolower(f); /* lowercase scheme */ |
1669 |
ap_str_tolower(f); /* lowercase scheme */ |
1647 |
ap_str_tolower(p + 3); /* lowercase hostname */ |
1670 |
} |
|
|
1671 |
ap_str_tolower(p); /* lowercase hostname */ |
1648 |
|
1672 |
|
1649 |
if (port == -1) { |
1673 |
if (port == -1) { |
1650 |
port = apr_uri_port_of_scheme(scheme); |
1674 |
port = apr_uri_port_of_scheme(scheme); |
Lines 1653-1660
static const char *
Link Here
|
1653 |
new = apr_array_push(conf->proxies); |
1677 |
new = apr_array_push(conf->proxies); |
1654 |
new->scheme = f; |
1678 |
new->scheme = f; |
1655 |
new->protocol = r; |
1679 |
new->protocol = r; |
1656 |
new->hostname = p + 3; |
1680 |
new->hostname = p; |
1657 |
new->port = port; |
1681 |
new->port = port; |
|
|
1682 |
new->auth = a; |
1658 |
new->regexp = reg; |
1683 |
new->regexp = reg; |
1659 |
new->use_regex = regex; |
1684 |
new->use_regex = regex; |
1660 |
return NULL; |
1685 |
return NULL; |
Lines 2608-2614
static const command_rec proxy_cmds[] =
Link Here
|
2608 |
AP_INIT_FLAG("ProxyRequests", set_proxy_req, NULL, RSRC_CONF, |
2633 |
AP_INIT_FLAG("ProxyRequests", set_proxy_req, NULL, RSRC_CONF, |
2609 |
"on if the true proxy requests should be accepted"), |
2634 |
"on if the true proxy requests should be accepted"), |
2610 |
AP_INIT_TAKE2("ProxyRemote", add_proxy_noregex, NULL, RSRC_CONF, |
2635 |
AP_INIT_TAKE2("ProxyRemote", add_proxy_noregex, NULL, RSRC_CONF, |
2611 |
"a scheme, partial URL or '*' and a proxy server"), |
2636 |
"a scheme, partial URL or '*' and a proxy server optional with auth"), |
2612 |
AP_INIT_TAKE2("ProxyRemoteMatch", add_proxy_regex, NULL, RSRC_CONF, |
2637 |
AP_INIT_TAKE2("ProxyRemoteMatch", add_proxy_regex, NULL, RSRC_CONF, |
2613 |
"a regex pattern and a proxy server"), |
2638 |
"a regex pattern and a proxy server"), |
2614 |
AP_INIT_FLAG("ProxyPassInterpolateEnv", ap_set_flag_slot_char, |
2639 |
AP_INIT_FLAG("ProxyPassInterpolateEnv", ap_set_flag_slot_char, |
Lines 3047-3054
APR_IMPLEMENT_EXTERNAL_HOOK_RUN_FIRST(proxy, PROXY, int, scheme_handler,
Link Here
|
3047 |
(request_rec *r, proxy_worker *worker, |
3072 |
(request_rec *r, proxy_worker *worker, |
3048 |
proxy_server_conf *conf, |
3073 |
proxy_server_conf *conf, |
3049 |
char *url, const char *proxyhost, |
3074 |
char *url, const char *proxyhost, |
3050 |
apr_port_t proxyport),(r,worker,conf, |
3075 |
apr_port_t proxyport, |
3051 |
url,proxyhost,proxyport),DECLINED) |
3076 |
const char *proxyauth), |
|
|
3077 |
(r,worker,conf, |
3078 |
url,proxyhost,proxyport, proxyauth),DECLINED) |
3052 |
APR_IMPLEMENT_EXTERNAL_HOOK_RUN_FIRST(proxy, PROXY, int, canon_handler, |
3079 |
APR_IMPLEMENT_EXTERNAL_HOOK_RUN_FIRST(proxy, PROXY, int, canon_handler, |
3053 |
(request_rec *r, char *url),(r, |
3080 |
(request_rec *r, char *url),(r, |
3054 |
url),DECLINED) |
3081 |
url),DECLINED) |