nginx-0.2.6-RELEASE import

    *) Change: while using load-balancing the time before the failed
       backend retry was decreased from 60 to 10 seconds.

    *) Change: the "proxy_pass_unparsed_uri" was canceled, the original URI
       now passed, if the URI part is omitted in "proxy_pass" directive.

    *) Feature: the "error_page" directive supports redirects and allows
       more flexible to change an error code.

    *) Change: the charset in the "Content-Type" header line now is ignored
       in proxied subrequests.

    *) Bugfix: if the URI was changed in the "if" block and request did not
       found new configuration, then the ngx_http_rewrite_module rules ran
       again.

    *) Bugfix: if the "set" directive set the ngx_http_geo_module variable
       in some configuration part, the this variable was not available in
       other configuration parts and the "using uninitialized variable"
       error was occurred; the bug had appeared in 0.2.2.
diff --git a/src/http/modules/ngx_http_charset_filter_module.c b/src/http/modules/ngx_http_charset_filter_module.c
index 2ec138f..51f115b 100644
--- a/src/http/modules/ngx_http_charset_filter_module.c
+++ b/src/http/modules/ngx_http_charset_filter_module.c
@@ -162,7 +162,8 @@
         return ngx_http_next_header_filter(r);
     }
 
-    if (ngx_strstr(r->headers_out.content_type.data, "charset") != NULL)
+    if (r->main == r
+        && ngx_strstr(r->headers_out.content_type.data, "charset") != NULL)
     {
         return ngx_http_next_header_filter(r);
     }
diff --git a/src/http/modules/ngx_http_fastcgi_module.c b/src/http/modules/ngx_http_fastcgi_module.c
index 9b317f9..c541807 100644
--- a/src/http/modules/ngx_http_fastcgi_module.c
+++ b/src/http/modules/ngx_http_fastcgi_module.c
@@ -148,11 +148,6 @@
     ngx_string("fastcgi_script_name");
 
 
-#if (NGX_PCRE)
-static ngx_str_t ngx_http_fastcgi_uri = ngx_string("/");
-#endif
-
-
 static ngx_conf_post_t  ngx_http_fastcgi_lowat_post =
     { ngx_http_fastcgi_lowat_check };
 
@@ -1448,7 +1443,6 @@
     conf->upstream.max_temp_file_size_conf = NGX_CONF_UNSET_SIZE; 
     conf->upstream.temp_file_write_size_conf = NGX_CONF_UNSET_SIZE;
 
-    conf->upstream.pass_unparsed_uri = NGX_CONF_UNSET;
     conf->upstream.method = NGX_CONF_UNSET_UINT;
     conf->upstream.pass_request_headers = NGX_CONF_UNSET;
     conf->upstream.pass_request_body = NGX_CONF_UNSET;
@@ -1602,16 +1596,6 @@
                               NGX_HTTP_FASTCGI_TEMP_PATH, 1, 2, 0,
                               ngx_garbage_collector_temp_handler, cf);
 
-    ngx_conf_merge_value(conf->upstream.pass_unparsed_uri,
-                              prev->upstream.pass_unparsed_uri, 0);
-
-    if (conf->upstream.pass_unparsed_uri && conf->upstream.location->len > 1) {
-        ngx_log_error(NGX_LOG_EMERG, cf->log, 0,
-                      "\"fastcgi_pass_unparsed_uri\" can be set for "
-                      "location \"/\" or given by regular expression.");
-        return NGX_CONF_ERROR;
-    }
-
     if (conf->upstream.method == NGX_CONF_UNSET_UINT) {
         conf->upstream.method = prev->upstream.method; 
     }
@@ -1812,6 +1796,10 @@
     ngx_unix_domain_upstream_t   unix_upstream;
 #endif
 
+    if (lcf->upstream.schema.len) {
+        return "is duplicate";
+    }
+
     value = cf->args->elts;
 
     if (ngx_strncasecmp(value[1].data, "unix:", 5) == 0) {
@@ -1828,6 +1816,8 @@
             return NGX_CONF_ERROR;
         }
 
+        lcf->peers->peer[0].uri_separator = "";
+
 #else
         ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
                            "the unix domain sockets are not supported "
@@ -1850,18 +1840,12 @@
 
     lcf->upstream.schema.len = sizeof("fastcgi://") - 1;
     lcf->upstream.schema.data = (u_char *) "fastcgi://";
-    lcf->upstream.uri.len = sizeof("/") - 1;
-    lcf->upstream.uri.data = (u_char *) "/";
 
     clcf = ngx_http_conf_get_module_loc_conf(cf, ngx_http_core_module);
 
     clcf->handler = ngx_http_fastcgi_handler;
 
-#if (NGX_PCRE)
-    lcf->upstream.location = clcf->regex ? &ngx_http_fastcgi_uri : &clcf->name;
-#else
     lcf->upstream.location = &clcf->name;
-#endif
 
     if (clcf->name.data[clcf->name.len - 1] == '/') {
         clcf->auto_redirect = 1;
diff --git a/src/http/modules/ngx_http_proxy_module.c b/src/http/modules/ngx_http_proxy_module.c
index fd41017..e1ee7b4 100644
--- a/src/http/modules/ngx_http_proxy_module.c
+++ b/src/http/modules/ngx_http_proxy_module.c
@@ -159,13 +159,6 @@
       offsetof(ngx_http_proxy_loc_conf_t, upstream.redirect_errors),
       NULL },
 
-    { ngx_string("proxy_pass_unparsed_uri"),
-      NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
-      ngx_conf_set_flag_slot,
-      NGX_HTTP_LOC_CONF_OFFSET,
-      offsetof(ngx_http_proxy_loc_conf_t, upstream.pass_unparsed_uri),
-      NULL },
-
     { ngx_string("proxy_set_header"),
       NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE2,
       ngx_conf_set_table_elt_slot,
@@ -342,11 +335,6 @@
 };
 
 
-#if (NGX_PCRE)
-static ngx_str_t ngx_http_proxy_uri = ngx_string("/");
-#endif
-
-
 static ngx_int_t
 ngx_http_proxy_handler(ngx_http_request_t *r)
 {   
@@ -432,7 +420,7 @@
 
     loc_len = r->valid_location ? u->conf->location->len : 0;
 
-    if (plcf->upstream.pass_unparsed_uri && r->valid_unparsed_uri) {
+    if (u->conf->uri.len == 0 && r->valid_unparsed_uri) {
         len += r->unparsed_uri.len;
 
     } else {
@@ -514,11 +502,15 @@
                              r->method_name.len + 1);
     }
 
-    if (plcf->upstream.pass_unparsed_uri && r->valid_unparsed_uri) {
+    u->uri.data = b->last;
+
+    if (u->conf->uri.len == 0 && r->valid_unparsed_uri) {
         b->last = ngx_cpymem(b->last, r->unparsed_uri.data,
                              r->unparsed_uri.len);
     } else {
-        b->last = ngx_cpymem(b->last, u->conf->uri.data, u->conf->uri.len);
+        if (r->valid_location) {
+            b->last = ngx_cpymem(b->last, u->conf->uri.data, u->conf->uri.len);
+        }
 
         if (escape) {
             ngx_escape_uri(b->last, r->uri.data + loc_len,
@@ -536,6 +528,8 @@
         }
     }
 
+    u->uri.len = b->last - u->uri.data;
+
     b->last = ngx_cpymem(b->last, ngx_http_proxy_version,
                          sizeof(ngx_http_proxy_version) - 1);
 
@@ -1312,7 +1306,6 @@
     conf->upstream.max_temp_file_size_conf = NGX_CONF_UNSET_SIZE;  
     conf->upstream.temp_file_write_size_conf = NGX_CONF_UNSET_SIZE;
 
-    conf->upstream.pass_unparsed_uri = NGX_CONF_UNSET;
     conf->upstream.method = NGX_CONF_UNSET_UINT;
     conf->upstream.pass_request_headers = NGX_CONF_UNSET;
     conf->upstream.pass_request_body = NGX_CONF_UNSET;
@@ -1467,16 +1460,6 @@
                               NGX_HTTP_PROXY_TEMP_PATH, 1, 2, 0,
                               ngx_garbage_collector_temp_handler, cf);
 
-    ngx_conf_merge_value(conf->upstream.pass_unparsed_uri,
-                              prev->upstream.pass_unparsed_uri, 0);
-
-    if (conf->upstream.pass_unparsed_uri && conf->upstream.location->len > 1) {
-        ngx_log_error(NGX_LOG_EMERG, cf->log, 0,
-                      "\"proxy_pass_unparsed_uri\" can be set for "
-                      "location \"/\" or given by regular expression.");
-        return NGX_CONF_ERROR;
-    }
-
     if (conf->upstream.method == NGX_CONF_UNSET_UINT) {
         conf->upstream.method = prev->upstream.method;
     }
@@ -1759,7 +1742,6 @@
 {
     ngx_http_proxy_loc_conf_t *plcf = conf;
 
-    ngx_uint_t                   i;
     ngx_str_t                   *value, *url;
     ngx_inet_upstream_t          inet_upstream;
     ngx_http_core_loc_conf_t    *clcf;
@@ -1767,6 +1749,10 @@
     ngx_unix_domain_upstream_t   unix_upstream;
 #endif
 
+    if (plcf->upstream.schema.len) {
+        return "is duplicate";
+    }
+
     value = cf->args->elts;
 
     url = &value[1];
@@ -1792,8 +1778,6 @@
             return NGX_CONF_ERROR;
         }
 
-        plcf->peers->peer[0].uri_separator = ":";
-
         plcf->host_header.len = sizeof("localhost") - 1;
         plcf->host_header.data = (u_char *) "localhost";
         plcf->upstream.uri = unix_upstream.uri;
@@ -1820,10 +1804,6 @@
             return NGX_CONF_ERROR;
         }
 
-        for (i = 0; i < plcf->peers->number; i++) {
-            plcf->peers->peer[i].uri_separator = "";
-        }
-
         plcf->host_header = inet_upstream.host_header;
         plcf->port_text = inet_upstream.port_text;
         plcf->upstream.uri = inet_upstream.uri;
@@ -1836,10 +1816,17 @@
 
     clcf->handler = ngx_http_proxy_handler;
 
-#if (NGX_PCRE)
-    plcf->upstream.location = clcf->regex ? &ngx_http_proxy_uri : &clcf->name;
-#else
     plcf->upstream.location = &clcf->name;
+
+#if (NGX_PCRE)
+
+    if (clcf->regex && plcf->upstream.uri.len) {
+        ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
+                           "\"proxy_pass\" may not have URI part in "
+                           "location given by regular expression");
+        return NGX_CONF_ERROR;
+    }
+
 #endif
 
     plcf->upstream.url = *url;
diff --git a/src/http/modules/ngx_http_rewrite_module.c b/src/http/modules/ngx_http_rewrite_module.c
index 693495e..c575d43 100644
--- a/src/http/modules/ngx_http_rewrite_module.c
+++ b/src/http/modules/ngx_http_rewrite_module.c
@@ -691,7 +691,7 @@
 
     if (pclcf->locations.elts == NULL) {
         if (ngx_array_init(&pclcf->locations, cf->pool, 4, sizeof(void *))
-                                                                  == NGX_ERROR)
+            == NGX_ERROR)
         {
             return NGX_CONF_ERROR;
         }
@@ -759,6 +759,10 @@
     if_code->next = (u_char *) lcf->codes->elts + lcf->codes->nelts
                                                 - (u_char *) if_code;
 
+    /* the code array belong to parent block */
+
+    nlcf->codes = NULL;
+
     return NGX_CONF_OK;
 }
 
@@ -1048,8 +1052,10 @@
         return NGX_CONF_ERROR;
     }
 
-    v->handler = ngx_http_rewrite_var;
-    v->data = index;
+    if (v->handler == NULL) {
+        v->handler = ngx_http_rewrite_var;
+        v->data = index;
+    }
 
     n = ngx_http_script_variables_count(&value[2]);