Limit request + whitelist = not using response code from backend? 0.8.54

Maxim Dounin mdounin at mdounin.ru
Tue Feb 19 13:18:12 UTC 2013


Hello!

On Tue, Feb 19, 2013 at 02:05:46PM +0100, DreamWerx wrote:

> Hi all,
> 
> I'm hoping someone can help me with a small issue.  I'm trying to
> implement rate limiting with a whitelist, and all in all it seems to
> be working, but
> the wrong response code is being sent back to the browser.
> 
> For example if the apache backend sends a 302 redirect response, nginx
> still sends a 200 back?  If I remove the mapping to code 200, it then
> sends a 418 back.
> Is there an easy fix for this?

Yes,

-   error_page 418 =200 @limitclient;
+   error_page 418 =    @limitclient;

See http://nginx.org/r/error_page.

Alternatively, you may want to use something like

    geo $limited { ... }

    map $limited $address {
        1        $binary_remote_address;
        0        "";
    }

    limit_req_zone $address zone=...;

to implement a whitelist (i.e., make sure the variable used in 
limit_req_zone is empty if you don't want the limit).

-- 
Maxim Dounin
http://nginx.com/support.html



More information about the nginx mailing list