deny by ip and redirect

Igor Sysoev igor at sysoev.ru
Sun Oct 17 21:39:50 MSD 2010


On Sun, Oct 17, 2010 at 08:42:56PM +0400, Igor Sysoev wrote:

> On Sun, Oct 17, 2010 at 08:33:36PM +0400, Igor Sysoev wrote:
> 
> > On Sun, Oct 17, 2010 at 12:29:14PM -0400, Ilan Berkner wrote:
> > 
> > > Thanks Igor, appreciate the information, is this something you expect to be
> > > done in coming versions?
> > 
> > The attached patch allows this.
> > It will be included in the next 0.8.53.
> 
> Sorry, this is wrong patch.

The new patch.


-- 
Igor Sysoev
http://sysoev.ru/en/
-------------- next part --------------
Index: src/http/ngx_http_core_module.c
===================================================================
--- src/http/ngx_http_core_module.c	(revision 3099)
+++ src/http/ngx_http_core_module.c	(working copy)
@@ -4069,19 +4069,15 @@
             return NGX_CONF_ERROR;
         }
 
-        if (overwrite >= 0) {
-            err->overwrite = overwrite;
+        err->overwrite = overwrite;
 
-        } else {
+        if (overwrite == -1) {
             switch (err->status) {
                 case NGX_HTTP_TO_HTTPS:
                 case NGX_HTTPS_CERT_ERROR:
                 case NGX_HTTPS_NO_CERT:
                     err->overwrite = NGX_HTTP_BAD_REQUEST;
-                    break;
-
                 default:
-                    err->overwrite = err->status;
                     break;
             }
         }
Index: src/http/ngx_http_special_response.c
===================================================================
--- src/http/ngx_http_special_response.c	(revision 3099)
+++ src/http/ngx_http_special_response.c	(working copy)
@@ -523,7 +523,9 @@
         r->expect_tested = 1;
     }
 
-    r->err_status = overwrite;
+    if (overwrite >= 0) {
+        r->err_status = overwrite;
+    }
 
     if (ngx_http_complex_value(r, &err_page->value, &uri) != NGX_OK) {
         return NGX_ERROR;
@@ -556,7 +558,7 @@
         return NGX_ERROR;
     }
 
-    r->err_status = NGX_HTTP_MOVED_TEMPORARILY;
+    r->err_status = overwrite > 0 ? overwrite : NGX_HTTP_MOVED_TEMPORARILY;
 
     location->hash = 1;
     ngx_str_set(&location->key, "Location");
@@ -570,7 +572,7 @@
         return ngx_http_send_refresh(r);
     }
 
-    return ngx_http_send_special_response(r, clcf, NGX_HTTP_MOVED_TEMPORARILY
+    return ngx_http_send_special_response(r, clcf, r->err_status
                                                    - NGX_HTTP_MOVED_PERMANENTLY
                                                    + NGX_HTTP_LEVEL_200);
 }


More information about the nginx mailing list