limit_req_zone for IPv6 subnets

Christian Staudte christian at staudte.it
Mon Apr 5 11:46:17 UTC 2021


Hi,

On 05.04.21 01:13, Maxim Dounin wrote:
> You can use anything as a key in limit_req_zone, including your 
> own variables.  If you want to limit IPv6 addresses per /64 
> subnets, something like this should work:
> 
> map $binary_remote_addr $subnet {
>     "~^(\C{8})"         $1;
>     default             $binary_remote_addr;
> }
> 
> limit_req_zone $subnet zone=one:10m rate=1r/s;

This seems to work, very nice! That should definitely be added to the
docs and maybe also to the blog post
(https://www.nginx.com/blog/rate-limiting-nginx/).

Regards, Chris


More information about the nginx mailing list