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