[PATCH] Conditional application of limit_conn directive

Maxim Dounin mdounin at mdounin.ru
Tue Sep 22 13:19:23 UTC 2020


Hello!

On Tue, Sep 22, 2020 at 04:53:25PM +1000, turchanov at farpost.com wrote:

> Patch with tests will follow
> 
> # HG changeset patch
> # User Sergei Turchanov <turchanov at farpost.com>
> # Date 1600756248 -36000
> #      Tue Sep 22 16:30:48 2020 +1000
> # Node ID 2cf4e00bb96b17142a82e5f1868197465cf5c194
> # Parent  052ecc68d35038b1b4adde12efe6249a92055f09
> Conditional application of limit_conn directive
> 
> Implemented conditional application of limit_conn directive.
> Since limit_conn directive cannot be used inside 'if' block, an optional
> parameter 'if=condition' was introduced to control whether the limit is
> applied or not. The limit will not be applied if the condition evaluates
> to "0" or an empty string.

Thank you for the patch.

Quoting the documentation (http://nginx.org/r/limit_conn_zone):

: Requests with an empty key value are not accounted.

That is, limit_conn can be used conditionally without any 
code changes.  The same applies to limit_req.

-- 
Maxim Dounin
http://mdounin.ru/


More information about the nginx-devel mailing list