Welcome! Log In Create A New Profile

Advanced

Question about limit_req_zone and max shared memory

February 22, 2021 05:36AM
I want to rate limit PHP requests with "client ip + vhost + same url" but on same servers sometimes I see:

[alert] 78841#0: could not allocate node in limit_req zone "req_limit_per_ip_per_uri"

which causes 429 errors in all domains.

-----

FreeBSD/amd64

-----

# Max connections

events {
worker_connections 16384;
}

# Rate limit

limit_req_zone "$binary_remote_addr$host$request_uri" zone=req_limit_per_ip_per_uri:10m rate=2r/s;

# Vhosts

server {

server_name www.example1.com;
...
location ~ [^/]\.php(/|$) {
...
limit_req zone=req_limit_per_ip_per_uri burst=20 nodelay;
...
}
...
}

server {

server_name www.example2.com;
...
location ~ [^/]\.php(/|$) {
...
limit_req zone=req_limit_per_ip_per_uri burst=20 nodelay;
...
}
...
}

----

Ιs it better to use different variables for key? Which is the max shared memory needed?
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Question about limit_req_zone and max shared memory

CyberCr33p February 22, 2021 05:36AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 80
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready