This limit_req configuration works if I hit php pages directly (index.php), but not if it hits /[pretty urls] and rewrites it to index.php?$args.
limit_req_zone $binary_remote_addr zone=dynamic:10M rate=1r/s;
limit_req_zone $binary_remote_addr zone=static:10M rate=60r/s;
location / {
limit_req zone=static burst=180;
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
limit_req zone=dynamic burst=5;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
set $fsn /index.php;
if (-f $document_root$fastcgi_script_name){
set $fsn $fastcgi_script_name;
}
fastcgi_pass unix:/var/run/php5-fpm.sock;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fsn;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fsn;
}
It is obviously getting to the right location because it passes to the backend, but the limit_req doesn't appear to be used. I can't find anything discussing this limitation in the docs. Does anyone have any ideas?
Edit: Commenting out the first one with zone=static allows the php processing one to work. To me this looks like a bug in limit_req.
It looks like this is just the way NGINX and the limit_req module work... perhaps in the future it will get better.
After a lot of digging I found an nginx forum post that talks about this http://forum.nginx.org/read.php?2,223426,223431 and it appears one or both of the following is true (I don't have the interest to dig into this any further).
So far the solution to my config is to remove the limit_req from / and setup a new location regex match for static files and put in the limit_req for static data there.