The limit_req happens at a later phase of query processing than the rewrite. So when you do the /test and /somesite the rewrite happens before limit. The URL the rewrite is targeting is not exactly '/' so the middle location isn't getting hit by the rewrite either to limit there. I suspect what you want is:
location = /test {
rewrite ^(.*)$ /test.txt;
}
location / {
limit_req zone=myzone burst=3 nodelay;
index lala.html;
}
location ~ /somesite {
rewrite ^(.*)$ /somesite.txt;
}
location = /test {
rewrite ^(.*)$ /test.txt;
}
location / {
limit_req zone=myzone burst=3 nodelay;
index lala.html;
}
location ~ /somesite {
rewrite ^(.*)$ /somesite.txt;
}