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