I'm using below nginx block. I want to exclude all requests for js and CSS files from nginx rate limiting. With my below nginx directives, rate limiting is excluded to all files apart from /api route. How to fix it? I want to only exclude js & css files from rate limiting. My nginx version is nginx/1.18.0 (Ubuntu).
limit_req_zone $binary_remote_addr zone=req_limit_per_ip:10m rate=1r/s;
server {
# other server directives...
# Location block for JavaScript files (no rate limiting)
location ~* \.(js|css)$ {
# No limit_req here, so no rate limiting applies
}
# General location block with rate limiting for other requests
location / {
limit_req zone=req_limit_per_ip burst=5 nodelay; # Rate limit applied here
}
location /api {
limit_req zone=req_limit_per_ip burst=5 nodelay; # Rate limit applied here
}
}