Welcome! Log In Create A New Profile

Advanced

Rate limiting for try_files

Marco Colli
January 26, 2019 04:06PM
Hello!

I cannot figure out how to apply a rate limit *only to static files* served
with try_files (and not for @app location). Is it possible?

Here's my configuration:

limit_req_zone $binary_remote_addr zone=mylimit:10m rate=2r/s;

server {
listen 80;
server_name example.com;

# serve the static file directly if it exists in the public Rails
folder...
try_files $uri @app;

location @app {
# ... otherwise send the request to the Rails application
proxy_pass http://app;
proxy_redirect off;
}
}


I know that I can use the following:
limit_req zone=mylimit burst=50 nodelay;

However where should I put that line? If I put it in the "server", then
also my @app will use that settings, which is not what I want... I just
want to put a limit specific for files served using try_files. Note that
static files can be in any location, even the root folder (e.g.
/favicon.ico and many others).


Any help would be greatly appreciated
Thanks


Marco Colli
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Rate limiting for try_files

Marco Colli January 26, 2019 04:06PM

Re: Rate limiting for try_files

Francis Daly January 27, 2019 04:44PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 168
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready