--- proxy_util.c.orig 2007-09-13 10:50:07.311449200 +0200 +++ proxy_util.c.orig 2007-09-13 10:50:06.592699200 +0200 @@ -20,6 +20,16 @@ #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 /* for getpid() */ #endif @@ -1394,14 +1404,46 @@ } 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; + + 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 */