
*** modules/proxy/proxy_util.c.orig     Tue Dec 19 22:56:16 2006
--- modules/proxy/proxy_util.c  Tue Sep  4 11:46:11 2007
***************
*** 20,25 ****
--- 20,35 ----
  #include "scoreboard.h"
  #include "apr_version.h"
  
+ #define PROXY_COPY_CONF_PARAMS(w, c) \
+     do {                             \
+         (w)->timeout              = (c)->timeout;               \
+         (w)->timeout_set          = (c)->timeout_set;           \
+         (w)->recv_buffer_size     = (c)->recv_buffer_size;      \
+         (w)->recv_buffer_size_set = (c)->recv_buffer_size_set;  \
+         (w)->io_buffer_size       = (c)->io_buffer_size;        \
+         (w)->io_buffer_size_set   = (c)->io_buffer_size_set;    \
+     } while (0)
+ 
  #if APR_HAVE_UNISTD_H
  #include <unistd.h>         /* for getpid() */
  #endif
***************
*** 1394,1407 ****
          }
          else if (r->proxyreq == PROXYREQ_REVERSE) {
              if (conf->reverse) {
-                 ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r,
-                               "proxy: *: found reverse proxy worker for %s",
-                                *url);
                  *balancer = NULL;
                  *worker = conf->reverse;
                  access_status = OK;
              }
!         }
      }
      else if (access_status == DECLINED && *balancer != NULL) {
          /* All the workers are busy */
--- 1404,1449 ----
          }
          else if (r->proxyreq == PROXYREQ_REVERSE) {
              if (conf->reverse) {
                *balancer = NULL;
+ 
+               char *c;
+               char url_copy[strlen(*url) + 1];
+ 
+               /* Make a copy of the URL where the path is truncated */
+               strcpy(url_copy, *url);
+               c = ap_strchr_c(url_copy, ':');
+ 
+               if ( !(c == NULL || c[1] != '/' || c[2] != '/' || c[3] == '\0') ) {
+                 c = ap_strchr_c(c+3, '/');
+                 if ( c[0] == '/' )
+                   c[1] = '\0';
+               }
+ 
+               const char *err = ap_proxy_add_worker(worker, conf->pool, conf, url_copy);
+               if (err) {
+                   ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r,
+                                 "proxy: unable to add new reverse proxy worker for %s - %s",
+                                 *url, err);
+               }
+               else
+               {
+                  PROXY_COPY_CONF_PARAMS((proxy_worker *) *worker,
+                                         (proxy_server_conf *) conf);
+ 
+                  ap_proxy_initialize_worker_share(conf, *worker, r->server);
+                  ap_proxy_initialize_worker(*worker, r->server);
+                  /* Do not disable worker in case of errors */
+                  (*worker)->s->status |= PROXY_WORKER_IGNORE_ERRORS;
+                  (*worker)->is_address_reusable = 1;
+               }
+ 
+               ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r,
+                               "proxy: *: found reverse proxy worker for %s",
+                               *url);
                  *worker = conf->reverse;
                  access_status = OK;
              }
!       }
      }
      else if (access_status == DECLINED && *balancer != NULL) {
          /* All the workers are busy */
