|
|
9364d6 |
diff --git a/modules/proxy/mod_proxy.c b/modules/proxy/mod_proxy.c
|
|
|
9364d6 |
index 34ed5ab..d00454e 100644
|
|
|
9364d6 |
--- a/modules/proxy/mod_proxy.c
|
|
|
9364d6 |
+++ b/modules/proxy/mod_proxy.c
|
|
|
9364d6 |
@@ -1200,11 +1200,20 @@ static int proxy_handler(request_rec *r)
|
|
|
9364d6 |
/* handle the scheme */
|
|
|
9364d6 |
ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, APLOGNO(01142)
|
|
|
9364d6 |
"Trying to run scheme_handler against proxy");
|
|
|
9364d6 |
+
|
|
|
9364d6 |
+ if (ents[i].creds) {
|
|
|
9364d6 |
+ apr_table_set(r->notes, "proxy-basic-creds", ents[i].creds);
|
|
|
9364d6 |
+ ap_log_rerror(APLOG_MARK, APLOG_TRACE1, 0, r,
|
|
|
9364d6 |
+ "Using proxy auth creds %s", ents[i].creds);
|
|
|
9364d6 |
+ }
|
|
|
9364d6 |
+
|
|
|
9364d6 |
access_status = proxy_run_scheme_handler(r, worker,
|
|
|
9364d6 |
conf, url,
|
|
|
9364d6 |
ents[i].hostname,
|
|
|
9364d6 |
ents[i].port);
|
|
|
9364d6 |
|
|
|
9364d6 |
+ if (ents[i].creds) apr_table_unset(r->notes, "proxy-basic-creds");
|
|
|
9364d6 |
+
|
|
|
9364d6 |
/* Did the scheme handler process the request? */
|
|
|
9364d6 |
if (access_status != DECLINED) {
|
|
|
9364d6 |
const char *cl_a;
|
|
|
9364d6 |
@@ -1614,8 +1623,8 @@ static void *merge_proxy_dir_config(apr_pool_t *p, void *basev, void *addv)
|
|
|
9364d6 |
return new;
|
|
|
9364d6 |
}
|
|
|
9364d6 |
|
|
|
9364d6 |
-static const char *
|
|
|
9364d6 |
- add_proxy(cmd_parms *cmd, void *dummy, const char *f1, const char *r1, int regex)
|
|
|
9364d6 |
+static const char *add_proxy(cmd_parms *cmd, void *dummy, const char *f1,
|
|
|
9364d6 |
+ const char *r1, const char *creds, int regex)
|
|
|
9364d6 |
{
|
|
|
9364d6 |
server_rec *s = cmd->server;
|
|
|
9364d6 |
proxy_server_conf *conf =
|
|
|
9364d6 |
@@ -1673,19 +1682,24 @@ static const char *
|
|
|
9364d6 |
new->port = port;
|
|
|
9364d6 |
new->regexp = reg;
|
|
|
9364d6 |
new->use_regex = regex;
|
|
|
9364d6 |
+ if (creds) {
|
|
|
9364d6 |
+ new->creds = apr_pstrcat(cmd->pool, "Basic ",
|
|
|
9364d6 |
+ ap_pbase64encode(cmd->pool, (char *)creds),
|
|
|
9364d6 |
+ NULL);
|
|
|
9364d6 |
+ }
|
|
|
9364d6 |
return NULL;
|
|
|
9364d6 |
}
|
|
|
9364d6 |
|
|
|
9364d6 |
-static const char *
|
|
|
9364d6 |
- add_proxy_noregex(cmd_parms *cmd, void *dummy, const char *f1, const char *r1)
|
|
|
9364d6 |
+static const char *add_proxy_noregex(cmd_parms *cmd, void *dummy, const char *f1,
|
|
|
9364d6 |
+ const char *r1, const char *creds)
|
|
|
9364d6 |
{
|
|
|
9364d6 |
- return add_proxy(cmd, dummy, f1, r1, 0);
|
|
|
9364d6 |
+ return add_proxy(cmd, dummy, f1, r1, creds, 0);
|
|
|
9364d6 |
}
|
|
|
9364d6 |
|
|
|
9364d6 |
-static const char *
|
|
|
9364d6 |
- add_proxy_regex(cmd_parms *cmd, void *dummy, const char *f1, const char *r1)
|
|
|
9364d6 |
+static const char *add_proxy_regex(cmd_parms *cmd, void *dummy, const char *f1,
|
|
|
9364d6 |
+ const char *r1, const char *creds)
|
|
|
9364d6 |
{
|
|
|
9364d6 |
- return add_proxy(cmd, dummy, f1, r1, 1);
|
|
|
9364d6 |
+ return add_proxy(cmd, dummy, f1, r1, creds, 1);
|
|
|
9364d6 |
}
|
|
|
9364d6 |
|
|
|
9364d6 |
PROXY_DECLARE(const char *) ap_proxy_de_socketfy(apr_pool_t *p, const char *url)
|
|
|
9364d6 |
@@ -2623,9 +2637,9 @@ static const command_rec proxy_cmds[] =
|
|
|
9364d6 |
"location, in regular expression syntax"),
|
|
|
9364d6 |
AP_INIT_FLAG("ProxyRequests", set_proxy_req, NULL, RSRC_CONF,
|
|
|
9364d6 |
"on if the true proxy requests should be accepted"),
|
|
|
9364d6 |
- AP_INIT_TAKE2("ProxyRemote", add_proxy_noregex, NULL, RSRC_CONF,
|
|
|
9364d6 |
+ AP_INIT_TAKE23("ProxyRemote", add_proxy_noregex, NULL, RSRC_CONF,
|
|
|
9364d6 |
"a scheme, partial URL or '*' and a proxy server"),
|
|
|
9364d6 |
- AP_INIT_TAKE2("ProxyRemoteMatch", add_proxy_regex, NULL, RSRC_CONF,
|
|
|
9364d6 |
+ AP_INIT_TAKE23("ProxyRemoteMatch", add_proxy_regex, NULL, RSRC_CONF,
|
|
|
9364d6 |
"a regex pattern and a proxy server"),
|
|
|
9364d6 |
AP_INIT_FLAG("ProxyPassInterpolateEnv", ap_set_flag_slot_char,
|
|
|
9364d6 |
(void*)APR_OFFSETOF(proxy_dir_conf, interpolate_env),
|
|
|
9364d6 |
diff --git a/modules/proxy/mod_proxy.h b/modules/proxy/mod_proxy.h
|
|
|
9364d6 |
index e137b11..7141473 100644
|
|
|
9364d6 |
--- a/modules/proxy/mod_proxy.h
|
|
|
9364d6 |
+++ b/modules/proxy/mod_proxy.h
|
|
|
9364d6 |
@@ -116,6 +116,7 @@ struct proxy_remote {
|
|
|
9364d6 |
const char *protocol; /* the scheme used to talk to this proxy */
|
|
|
9364d6 |
const char *hostname; /* the hostname of this proxy */
|
|
|
9364d6 |
ap_regex_t *regexp; /* compiled regex (if any) for the remote */
|
|
|
9364d6 |
+ const char *creds; /* auth credentials (if any) for the proxy */
|
|
|
9364d6 |
int use_regex; /* simple boolean. True if we have a regex pattern */
|
|
|
9364d6 |
apr_port_t port; /* the port for this proxy */
|
|
|
9364d6 |
};
|
|
|
9364d6 |
diff --git a/modules/proxy/proxy_util.c b/modules/proxy/proxy_util.c
|
|
|
9364d6 |
index 4f6c458..a3999ec 100644
|
|
|
9364d6 |
--- a/modules/proxy/proxy_util.c
|
|
|
9364d6 |
+++ b/modules/proxy/proxy_util.c
|
|
|
9364d6 |
@@ -2433,11 +2433,14 @@ ap_proxy_determine_connection(apr_pool_t *p, request_rec *r,
|
|
|
9364d6 |
* So let's make it configurable by env.
|
|
|
9364d6 |
* The logic here is the same used in mod_proxy_http.
|
|
|
9364d6 |
*/
|
|
|
9364d6 |
- proxy_auth = apr_table_get(r->headers_in, "Proxy-Authorization");
|
|
|
9364d6 |
+ proxy_auth = apr_table_get(r->notes, "proxy-basic-creds");
|
|
|
9364d6 |
+ if (proxy_auth == NULL)
|
|
|
9364d6 |
+ proxy_auth = apr_table_get(r->headers_in, "Proxy-Authorization");
|
|
|
9364d6 |
+
|
|
|
9364d6 |
if (proxy_auth != NULL &&
|
|
|
9364d6 |
proxy_auth[0] != '\0' &&
|
|
|
9364d6 |
- r->user == NULL && /* we haven't yet authenticated */
|
|
|
9364d6 |
- apr_table_get(r->subprocess_env, "Proxy-Chain-Auth")) {
|
|
|
9364d6 |
+ (r->user == NULL /* we haven't yet authenticated */
|
|
|
9364d6 |
+ || apr_table_get(r->subprocess_env, "Proxy-Chain-Auth"))) {
|
|
|
9364d6 |
forward->proxy_auth = apr_pstrdup(conn->pool, proxy_auth);
|
|
|
9364d6 |
}
|
|
|
9364d6 |
}
|
|
|
9364d6 |
@@ -2659,7 +2662,8 @@ static apr_status_t send_http_connect(proxy_conn_rec *backend,
|
|
|
9364d6 |
nbytes = apr_snprintf(buffer, sizeof(buffer),
|
|
|
9364d6 |
"CONNECT %s:%d HTTP/1.0" CRLF,
|
|
|
9364d6 |
forward->target_host, forward->target_port);
|
|
|
9364d6 |
- /* Add proxy authorization from the initial request if necessary */
|
|
|
9364d6 |
+ /* Add proxy authorization from the configuration, or initial
|
|
|
9364d6 |
+ * request if necessary */
|
|
|
9364d6 |
if (forward->proxy_auth != NULL) {
|
|
|
9364d6 |
nbytes += apr_snprintf(buffer + nbytes, sizeof(buffer) - nbytes,
|
|
|
9364d6 |
"Proxy-Authorization: %s" CRLF,
|
|
|
9364d6 |
@@ -3554,6 +3558,7 @@ PROXY_DECLARE(int) ap_proxy_create_hdrbrgd(apr_pool_t *p,
|
|
|
9364d6 |
apr_bucket *e;
|
|
|
9364d6 |
int do_100_continue;
|
|
|
9364d6 |
conn_rec *origin = p_conn->connection;
|
|
|
9364d6 |
+ const char *creds;
|
|
|
9364d6 |
proxy_dir_conf *dconf = ap_get_module_config(r->per_dir_config, &proxy_module);
|
|
|
9364d6 |
|
|
|
9364d6 |
/*
|
|
|
9364d6 |
@@ -3739,6 +3744,11 @@ PROXY_DECLARE(int) ap_proxy_create_hdrbrgd(apr_pool_t *p,
|
|
|
9364d6 |
return HTTP_BAD_REQUEST;
|
|
|
9364d6 |
}
|
|
|
9364d6 |
|
|
|
9364d6 |
+ creds = apr_table_get(r->notes, "proxy-basic-creds");
|
|
|
9364d6 |
+ if (creds) {
|
|
|
9364d6 |
+ apr_table_mergen(r->headers_in, "Proxy-Authorization", creds);
|
|
|
9364d6 |
+ }
|
|
|
9364d6 |
+
|
|
|
9364d6 |
/* send request headers */
|
|
|
9364d6 |
headers_in_array = apr_table_elts(r->headers_in);
|
|
|
9364d6 |
headers_in = (const apr_table_entry_t *) headers_in_array->elts;
|