# Anyway to limit amount of requests to no more then 20 requests per hour for each file?

**URL:** <https://www.ruby-forum.com/t/anyway-to-limit-amount-of-requests-to-no-more-then-20-requests-per-hour-for-each-file/220319>\
**Category:** NGINX\
**Created:** [June 5, 2012, 10:30pm UTC](https://www.ruby-forum.com/t/anyway-to-limit-amount-of-requests-to-no-more-then-20-requests-per-hour-for-each-file/220319 "2012-06-05T22:30:56Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![aris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/258eb7/32.png) [@aris](https://www.ruby-forum.com/u/aris)\
**Post date:** [June 5, 2012, 10:30pm UTC](https://www.ruby-forum.com/t/anyway-to-limit-amount-of-requests-to-no-more-then-20-requests-per-hour-for-each-file/220319/1 "2012-06-05T22:30:56Z")

</div>

Hello,

Iam trying to avoid a seperate location {} for each file, instead just  
limit the amount of reqeusts per second based on each object.

Iam sure there must be a way.

Thanks

Joseph

---

<div class="post-metadata">

**Author:** ![jchengj](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/d78d45/32.png) [@jchengj](https://www.ruby-forum.com/u/jchengj)\
**Post date:** [June 5, 2012, 10:56pm UTC](https://www.ruby-forum.com/t/anyway-to-limit-amount-of-requests-to-no-more-then-20-requests-per-hour-for-each-file/220319/2 "2012-06-05T22:56:04Z")

</div>

On Wednesday 06 June 2012 00:30:26 Joseph C. wrote:

> Hello,
> 
> Iam trying to avoid a seperate location {} for each file, instead just  
> limit the amount of reqeusts per second based on each object.

If you’re happy with 60 requests per hour, then you can take advantage  
of  
the http\_limit\_req module.

> **[Module ngx\_http\_limit\_req\_module](http://nginx.org/en/docs/http/ngx_http_limit_req_module.html)**

limit\_req\_zone $uri zone=one:32m rate=1r/m;

wbr, Valentin V. Bartenev

---

<div class="post-metadata">

**Author:** ![jchengj](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/d78d45/32.png) [@jchengj](https://www.ruby-forum.com/u/jchengj)\
**Post date:** [June 6, 2012, 12:19am UTC](https://www.ruby-forum.com/t/anyway-to-limit-amount-of-requests-to-no-more-then-20-requests-per-hour-for-each-file/220319/3 "2012-06-06T00:19:04Z")

</div>

Great…

So all I need is that single line in the httpd section, or server  
section?

limit\_req\_zone $uri zone=one:32m rate=1r/m;

Iam thinking I need some other line to actually apply the limit such as  
this?

location / { limit\_req zone=one; proxy\_pass [http://backend1](http://backend1); }

Or something like this?

Joseph

---

<div class="post-metadata">

**Author:** ![jchengj](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/d78d45/32.png) [@jchengj](https://www.ruby-forum.com/u/jchengj)\
**Post date:** [June 6, 2012, 12:25am UTC](https://www.ruby-forum.com/t/anyway-to-limit-amount-of-requests-to-no-more-then-20-requests-per-hour-for-each-file/220319/4 "2012-06-06T00:25:30Z")

</div>

On Wednesday 06 June 2012 02:18:46 Joseph C. wrote:  
[…]

> Iam thinking I need some other line to actually apply the limit such as  
> this?
> 
> location / { limit\_req zone=one; proxy\_pass [http://backend1](http://backend1); }
> 
> Or something like this?

Yes, that’s right. You also need limit\_req directive in the place where  
do you  
want to apply the limit.

wbr, Valentin V. Bartenev
