nginx-0.0.3-2004-03-19-08:25:53 import
diff --git a/src/http/modules/ngx_http_index_handler.c b/src/http/modules/ngx_http_index_handler.c
index 12e96f1..de609ac 100644
--- a/src/http/modules/ngx_http_index_handler.c
+++ b/src/http/modules/ngx_http_index_handler.c
@@ -21,7 +21,7 @@
 } ngx_http_index_ctx_t;
 
 
-#define NGX_HTTP_DEFAULT_INDEX   (u_char *) "index.html"
+#define NGX_HTTP_DEFAULT_INDEX   "index.html"
 
 
 static ngx_int_t ngx_http_index_test_dir(ngx_http_request_t *r,
@@ -98,7 +98,6 @@
 int ngx_http_index_handler(ngx_http_request_t *r)
 {
     u_char                     *name;
-    size_t                      len;
     ngx_fd_t                    fd;
     ngx_int_t                   rc;
     ngx_str_t                  *index;
@@ -161,18 +160,38 @@
 
 #endif
 
-        len = clcf->root.len + r->uri.len + ilcf->max_index_len;
-        if (!(ctx->path.data = ngx_palloc(r->pool, len))) {
+        ctx->path.data = ngx_palloc(r->pool, clcf->root.len + r->uri.len
+                                             + ilcf->max_index_len
+                                             - clcf->alias * clcf->name.len);
+        if (ctx->path.data == NULL) {
             return NGX_HTTP_INTERNAL_SERVER_ERROR;
         }
 
         ctx->redirect.data = ngx_cpymem(ctx->path.data, clcf->root.data,
                                         clcf->root.len);
-        ctx->last = ngx_cpystrn(ctx->redirect.data, r->uri.data,
-                                r->uri.len + 1);
-        ctx->path.len = ctx->last - ctx->path.data;
+
+        if (clcf->alias) {
+            ctx->last = ngx_cpystrn(ctx->redirect.data,
+                                    r->uri.data + clcf->name.len,
+                                    r->uri.len + 1 - clcf->name.len);
+
+            /*
+             * aliases usually have trailling "/",
+             * set it in the start of the possible redirect
+             */
+
+            if (*ctx->redirect.data != '/') {
+                ctx->redirect.data--; 
+            }
+
+        } else {
+            ctx->last = ngx_cpystrn(ctx->redirect.data, r->uri.data,
+                                    r->uri.len + 1);
+        }
     }
 
+    ctx->path.len = ctx->last - ctx->path.data;
+
     index = ilcf->indices.elts;
     for (/* void */; ctx->index < ilcf->indices.nelts; ctx->index++) {
 
@@ -398,7 +417,7 @@
 
         ngx_test_null(index, ngx_push_array(&conf->indices), NGX_CONF_ERROR);
         index->len = sizeof(NGX_HTTP_DEFAULT_INDEX) - 1;
-        index->data = NGX_HTTP_DEFAULT_INDEX;
+        index->data = (u_char *) NGX_HTTP_DEFAULT_INDEX;
         conf->max_index_len = sizeof(NGX_HTTP_DEFAULT_INDEX);
 
         return NGX_CONF_OK;
diff --git a/src/http/modules/proxy/ngx_http_proxy_upstream.c b/src/http/modules/proxy/ngx_http_proxy_upstream.c
index f4bc1c4..d72f09e 100644
--- a/src/http/modules/proxy/ngx_http_proxy_upstream.c
+++ b/src/http/modules/proxy/ngx_http_proxy_upstream.c
@@ -85,8 +85,8 @@
             return NGX_DONE;
         }
 
-        if (rc == NGX_ERROR) {
-            return NGX_HTTP_INTERNAL_SERVER_ERROR;
+        if (rc >= NGX_HTTP_SPECIAL_RESPONSE || rc == NGX_ERROR) {
+            return rc;
         }
     }
 
@@ -1243,8 +1243,8 @@
 #endif
 
         if (ep->upstream_done || ep->upstream_eof || ep->upstream_error) {
-            ngx_log_debug0(NGX_LOG_DEBUG_HTTP, ev->log, 0,
-                           "http proxy upstream exit");
+            ngx_log_debug1(NGX_LOG_DEBUG_HTTP, ev->log, 0,
+                           "http proxy upstream exit: " PTR_FMT, ep->out);
             ngx_http_busy_unlock(p->lcf->busy_lock, &p->busy_lock);
             ngx_http_proxy_finalize_request(p, 0);
             return;