51b2b9
diff --git a/modules/mappers/mod_rewrite.c b/modules/mappers/mod_rewrite.c
51b2b9
index c4109d6..b89d3e4 100644
51b2b9
--- a/modules/mappers/mod_rewrite.c
51b2b9
+++ b/modules/mappers/mod_rewrite.c
51b2b9
@@ -599,6 +599,13 @@ static unsigned is_absolute_uri(char *uri, int *supportsqs)
51b2b9
             return 6;
51b2b9
         }
51b2b9
         break;
51b2b9
+
51b2b9
+    case 'u':
51b2b9
+    case 'U':
51b2b9
+        if (!ap_cstr_casecmpn(uri, "nix:", 4)) {        /* unix:     */
51b2b9
+            *sqs = 1;
51b2b9
+            return (uri[4] == '/' && uri[5] == '/') ? 7 : 5;
51b2b9
+        }
51b2b9
     }
51b2b9
 
51b2b9
     return 0;
af01b2
diff --git a/modules/proxy/mod_proxy.c b/modules/proxy/mod_proxy.c
af01b2
index 506a046..29a39f8 100644
af01b2
--- a/modules/proxy/mod_proxy.c
af01b2
+++ b/modules/proxy/mod_proxy.c
af01b2
@@ -1442,7 +1442,7 @@ static char *de_socketfy(apr_pool_t *p, char *url)
af01b2
      * the UDS path... ignore it
af01b2
      */
af01b2
     if (!strncasecmp(url, "unix:", 5) &&
af01b2
-        ((ptr = ap_strchr(url, '|')) != NULL)) {
af01b2
+        ((ptr = ap_strchr_c(url + 5, '|')) != NULL)) {
af01b2
         /* move past the 'unix:...|' UDS path info */
af01b2
         char *ret, *c;
af01b2
 
af01b2
diff --git a/modules/proxy/proxy_util.c b/modules/proxy/proxy_util.c
51b2b9
index ca6cb87..e5862f8 100644
af01b2
--- a/modules/proxy/proxy_util.c
af01b2
+++ b/modules/proxy/proxy_util.c
51b2b9
@@ -2010,8 +2010,7 @@ PROXY_DECLARE(int) ap_proxy_pre_request(proxy_worker **worker,
51b2b9
         }
51b2b9
         else if (r->proxyreq == PROXYREQ_REVERSE) {
51b2b9
             if (conf->reverse) {
51b2b9
-                char *ptr;
51b2b9
-                char *ptr2;
51b2b9
+                char *uds_url = r->filename + 6, *origin_url;
51b2b9
                 ap_log_rerror(APLOG_MARK, APLOG_TRACE2, 0, r,
51b2b9
                               "*: found reverse proxy worker for %s", *url);
51b2b9
                 *balancer = NULL;
51b2b9
@@ -2032,25 +2031,38 @@ PROXY_DECLARE(int) ap_proxy_pre_request(proxy_worker **worker,
af01b2
                  * check to see if r->filename starts with 'proxy:'
af01b2
                  */
af01b2
                 if (apr_table_get(r->notes, "rewrite-proxy") &&
af01b2
-                    (ptr2 = ap_strcasestr(r->filename, "unix:")) &&
af01b2
-                    (ptr = ap_strchr(ptr2, '|'))) {
51b2b9
+                    !ap_cstr_casecmpn(uds_url, "unix:", 5) &&
51b2b9
+                    (origin_url = ap_strchr(uds_url + 5, '|'))) {
af01b2
+
51b2b9
+                    char *uds_path = NULL;
51b2b9
+                    apr_size_t url_len;
af01b2
                     apr_uri_t urisock;
af01b2
                     apr_status_t rv;
51b2b9
-                    *ptr = '\0';
51b2b9
-                    rv = apr_uri_parse(r->pool, ptr2, &urisock);
51b2b9
-                    if (rv == APR_SUCCESS) {
51b2b9
-                        char *rurl = ptr+1;
51b2b9
-                        char *sockpath = ap_runtime_dir_relative(r->pool, urisock.path);
51b2b9
-                        apr_table_setn(r->notes, "uds_path", sockpath);
51b2b9
-                        *url = apr_pstrdup(r->pool, rurl); /* so we get the scheme for the uds */
51b2b9
-                        /* r->filename starts w/ "proxy:", so add after that */
51b2b9
-                        memmove(r->filename+6, rurl, strlen(rurl)+1);
51b2b9
-                        ap_log_rerror(APLOG_MARK, APLOG_TRACE2, 0, r,
51b2b9
-                                      "*: rewrite of url due to UDS(%s): %s (%s)",
51b2b9
-                                      sockpath, *url, r->filename);
51b2b9
+
51b2b9
+                    *origin_url = '\0';
51b2b9
+                    rv = apr_uri_parse(r->pool, uds_url, &urisock);
51b2b9
+                    *origin_url++ = '|';
51b2b9
+
51b2b9
+                    if (rv == APR_SUCCESS && urisock.path && (!urisock.hostname
51b2b9
+                                                              || !urisock.hostname[0])) {
51b2b9
+                         uds_path = ap_runtime_dir_relative(r->pool, urisock.path);
51b2b9
                     }
51b2b9
-                    else {
51b2b9
-                        *ptr = '|';
51b2b9
+
51b2b9
+                    if (!uds_path) {
51b2b9
+                         ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(10292)
51b2b9
+                         "Invalid proxy UDS filename (%s)", r->filename);
51b2b9
+                         access_status = HTTP_INTERNAL_SERVER_ERROR;
51b2b9
+                    } else {
51b2b9
+                         apr_table_setn(r->notes, "uds_path", uds_path);
51b2b9
+
51b2b9
+                         /* Remove the UDS path from *url and r->filename */
51b2b9
+                         url_len = strlen(origin_url);
51b2b9
+                         *url = apr_pstrmemdup(r->pool, origin_url, url_len);
51b2b9
+                         memcpy(uds_url, *url, url_len + 1);
51b2b9
+
51b2b9
+                         ap_log_rerror(APLOG_MARK, APLOG_TRACE2, 0, r,
51b2b9
+                               "*: rewrite of url due to UDS(%s): %s (%s)",
51b2b9
+                               uds_path, *url, r->filename);
51b2b9
                     }
51b2b9
                 }
51b2b9
             }