[PATCH 2 of 5] Fix error_page status code change in redirect
Maxim Dounin
mdounin at mdounin.ru
Tue Nov 2 06:57:32 MSK 2010
# HG changeset patch
# User Maxim Dounin <mdounin at mdounin.ru>
# Date 1288669812 -10800
# Node ID 49670f58d178cbef2108a76676b8d79cf2cb648b
# Parent 1e3045c3de6be5718359f4e0e3af9007f3da50aa
Fix error_page status code change in redirect.
Using codes other than 301, 302 and 303 resulted in unexpected behaviour. E.g.
something like
error_page 404 =200 http://localhost/;
resulted in "[alert] ... writev() failed (14: Bad address)" messages and no
reply returned. See here for initial report:
http://nginx.org/pipermail/nginx-ru/2010-October/037506.html
The same problem appears when redirecting special error codes which has
implict code changes, e.g. 497. See here for report:
http://nginx.org/pipermail/nginx/2010-November/023402.html
diff --git a/src/http/ngx_http_special_response.c b/src/http/ngx_http_special_response.c
--- a/src/http/ngx_http_special_response.c
+++ b/src/http/ngx_http_special_response.c
@@ -557,7 +557,14 @@ ngx_http_send_error_page(ngx_http_reques
return NGX_ERROR;
}
- r->err_status = overwrite > 0 ? overwrite : NGX_HTTP_MOVED_TEMPORARILY;
+ if (overwrite >= NGX_HTTP_MOVED_PERMANENTLY
+ && overwrite < NGX_HTTP_LAST_LEVEL_300)
+ {
+ r->err_status = overwrite;
+
+ } else {
+ r->err_status = NGX_HTTP_MOVED_TEMPORARILY;
+ }
location->hash = 1;
ngx_str_set(&location->key, "Location");
More information about the nginx-devel
mailing list