diff src/http/ngx_http_special_response.c @ 104:146eff53ab60 NGINX_0_2_6

nginx 0.2.6 *) 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; bug appeared in 0.2.2.
author Igor Sysoev <http://sysoev.ru>
date Wed, 05 Oct 2005 00:00:00 +0400
parents f63280c59dd5
children df17fbafec8f
line wrap: on
line diff
--- a/src/http/ngx_http_special_response.c
+++ b/src/http/ngx_http_special_response.c
@@ -283,18 +283,31 @@ ngx_http_special_response_handler(ngx_ht
         for (i = 0; i < clcf->error_pages->nelts; i++) {
 
             if (err_page[i].status == error) {
-
-                if (err_page[i].overwrite) {
-                    r->err_status = err_page[i].overwrite;
-                } else {
-                    r->err_status = error;
-                }
-
+                r->err_status = err_page[i].overwrite;
                 r->err_ctx = r->ctx;
 
                 r->method = NGX_HTTP_GET;
 
-                return ngx_http_internal_redirect(r, &err_page[i].uri, NULL);
+                if (err_page[i].uri.data[0] == '/') {
+                    return ngx_http_internal_redirect(r, &err_page[i].uri,
+                                                      NULL);
+                }
+
+                r->headers_out.location =
+                                        ngx_list_push(&r->headers_out.headers);
+
+                if (r->headers_out.location) {
+                    r->err_status = NGX_HTTP_MOVED_TEMPORARILY;
+                    error = NGX_HTTP_MOVED_TEMPORARILY;
+
+                    r->headers_out.location->hash = 1;
+                    r->headers_out.location->key.len = sizeof("Location") - 1;
+                    r->headers_out.location->key.data = (u_char *) "Location";
+                    r->headers_out.location->value = err_page[i].uri;
+
+                } else {
+                    error = NGX_HTTP_INTERNAL_SERVER_ERROR;
+                }
             }
         }
     }