# Define the rate limit zone
limit_req_zone $binary_remote_addr zone=one:10m rate=10r/s;
server {
# Exclude CSS, JS, and image files from rate limiting
location ~* \.(css|js|jpg|jpeg|png|gif|webp|svg|ico)$ {
# No rate limiting applied for these file types
# You can put other configurations here if necessary
}
# Apply rate limiting to all requests
location / {
limit_req zone=one burst=10 nodelay;
}
}
The above nginx config will process the first 10 requests from the same IP address for non-asset file requests, and will continue procesing the next 10 requests right away, and reject the 21th request and afterwards. This is useful to prevent DDoS attack.