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