limit_req and limit_conn in rewrite modules if statement

Maxim Dounin mdounin at mdounin.ru
Tue Nov 19 02:44:31 UTC 2013


Hello!

On Tue, Nov 19, 2013 at 12:35:19AM +0000, Francis Daly wrote:

> On Mon, Nov 18, 2013 at 02:49:27PM -0500, Nam wrote:
> 
> Hi there,
> 
> > I would like to see if it's possible to get limit_conn and limit_req
> > working with the rewrite modules if statement.
> 
> Not according to the current documentation.
> 
> I suspect that patches will be welcome, if they fit the usual criteria.

Not really.  Pathes to enable directives in if-in-location context 
are not considered.  Instead, directives should be able to work 
with variables.

In case of limit_req / limit_conn, variables support is already 
here.  Whitelisting can be easily done with something like this:

    map $whitelist $limit {
        default    $binary_remote_addr;
        1          "";
    }

    limit_req_zone $limit zone=one:10m rate=1r/s;

    server {
        ...

        set $whitelist "";

        if (...) {
            set $whitelist 1;
        }

        limit_req one;

        ...
    }

[...]

-- 
Maxim Dounin
http://nginx.org/en/donation.html



More information about the nginx mailing list