Question about limit_req_zone and max shared memory
Christos Chatzaras
chris at cretaforce.gr
Mon Feb 22 10:35:44 UTC 2021
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?
More information about the nginx
mailing list