<div dir="ltr"><div dir="ltr"><div>Hello!</div><div><br></div><div>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?</div><div><br></div><div>Here's my configuration:</div><div><br></div><div>limit_req_zone $binary_remote_addr zone=mylimit:10m rate=2r/s;</div><div><br></div><div>server {</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">    </span>listen 80;</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">     </span>server_name <a href="http://example.com">example.com</a>;</div><div><br></div><div>        # serve the static file directly if it exists in the public Rails folder...</div><div><span class="gmail-Apple-tab-span" style="white-space:pre"> </span>try_files $uri @app;</div><div><br></div><div><span class="gmail-Apple-tab-span" style="white-space:pre">  </span>location @app {</div><div>                # ... otherwise send the request to the Rails application</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">                </span>proxy_pass <a href="http://app">http://app</a>;</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">          </span>proxy_redirect off;</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">    </span>}</div><div>}</div><div><br></div><div><br></div><div>I know that I can use the following:</div><div>limit_req zone=mylimit burst=50 nodelay;</div><div><br></div><div>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).</div><div><br></div><div><br></div><div>Any help would be greatly appreciated</div><div>Thanks</div><div><br></div><div><br></div><div>Marco Colli</div></div></div>