I want configure different rate limiting for php-fpm.
I want to:
- static files had no limits,
- PHP requests had limits,
- PHP requests to
/ admin /.+
had different limits.
I have problem with implementation point 3. Now I test:
limit_req_zone $binary_remote_addr zone=php:10m rate=2r/s;
limit_req_zone $binary_remote_addr zone=admin:10m rate=9r/s;
server {
location / {
try_files $uri $uri/ /index.php?$args;
}
limit_req_status 429;
# limitng works, server return 404
location ~ /admin/ {limit_req zone=admin...}
location ~ [^/]\.php(/|$) {
limit_req zone=php burst=9 delay=4;
#limit_req not allowed here
if($request_uri ~ /admin) {limit_req zone=admin...}
#not update limits (lower)
location ~ ^/admin/ {limit_req zone=admin...}
#negative matching returns index.php content
location location ~ ^/(?!(admin)) {limit_req zone=php...}
}
}
Also is limit_req_zone $request_uri
but if I understand, this create different pools for /admin/1
and /admin/2
.
//update 1:
I need different pools for request like:
/index.php?/.*
and less strict for /index.php?/admin/.*