1

I set up a ratelimit in my nginx config. Usually you would define a location and define the rate limit zone. I want the zone to apply on ALL files on the web server.

limit_req_zone $binary_remote_addr zone=zone1:3m rate=5r/m;
limit_req_status 429;

server {
    listen 80 http2;
    listen 443 ssl http2;

    server_name SERVERNAME;

    root /var/www/cdn/public_html/;

    #SSL Config
    ssl_certificate PATH;
    ssl_certificate_key PATH;

    location / {
        limit_req zone=zone1 nodelay;
    }
}

I know that the location / does not work. That's why I am asking how to apply it to all files.

Example what i mean by a file /files/foo.zip

Hemanth Kumar
  • 314
  • 2
  • 7
0xPenis
  • 11
  • 2

1 Answers1

3

The limit_req directive may appear in the http, server or location contexts.

Your location / block should work, if it is the only location in that configuration (as your example implies).

But to apply it to the entire server, the obvious placement would be the server block.

Richard Smith
  • 12,834
  • 2
  • 21
  • 29