# Limit connection

**URL:** <https://www.ruby-forum.com/t/limit-connection/206528>\
**Category:** NGINX\
**Created:** [May 4, 2011, 7:24am UTC](https://www.ruby-forum.com/t/limit-connection/206528 "2011-05-04T07:24:37Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![dubstep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/cdc98d/32.png) [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Post date:** [May 4, 2011, 7:24am UTC](https://www.ruby-forum.com/t/limit-connection/206528/1 "2011-05-04T07:24:37Z")

</div>

Hello,  
I want to limit the number of connection per hour from IP range.

For example, I want to limit every hour, each IP can only visit our  
website for 5 times.

How can I write the config?

There is limit\_req, which limit the connection rate, used for DDos  
control.  
But it is different from my requirement.

Thanks,  
Yanxin

---

<div class="post-metadata">

**Author:** ![yanxin\_z](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/d6d6ee/32.png) [@yanxin\_z](https://www.ruby-forum.com/u/yanxin_z)\
**Post date:** [May 4, 2011, 7:28am UTC](https://www.ruby-forum.com/t/limit-connection/206528/2 "2011-05-04T07:28:44Z")

</div>

You might be better off researching a solution with iptables

On 5/4/11, Yanxin Z. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> But it is different from my requirement.  
> [mailman.nginx.org archive](http://nginx.org/mailman/listinfo/nginx)

–  
–C

“The dumber people think you are, the more surprised they’re going to  
be when you kill them.” - Sir William Clayton

---

<div class="post-metadata">

**Author:** ![yanxin\_z](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/d6d6ee/32.png) [@yanxin\_z](https://www.ruby-forum.com/u/yanxin_z)\
**Post date:** [May 4, 2011, 5:38pm UTC](https://www.ruby-forum.com/t/limit-connection/206528/3 "2011-05-04T17:38:56Z")

</div>

Thanks Chris.  
Do you have example I can refer?  
Yanxin

---

<div class="post-metadata">

**Author:** ![yanxin\_z](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/d6d6ee/32.png) [@yanxin\_z](https://www.ruby-forum.com/u/yanxin_z)\
**Post date:** [May 4, 2011, 6:37pm UTC](https://www.ruby-forum.com/t/limit-connection/206528/4 "2011-05-04T18:37:10Z")

</div>

Many are available online in regards to SSH limiting however you have  
to put in IP ranges of people you do not want to limit, which could be  
very hard. What exactly are you trying to do?

On 5/4/11, Yanxin Z. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> [mailman.nginx.org archive](http://nginx.org/mailman/listinfo/nginx)

–  
–C

“The dumber people think you are, the more surprised they’re going to  
be when you kill them.” - Sir William Clayton

---

<div class="post-metadata">

**Author:** ![yanxin\_z](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/d6d6ee/32.png) [@yanxin\_z](https://www.ruby-forum.com/u/yanxin_z)\
**Post date:** [May 5, 2011, 12:21am UTC](https://www.ruby-forum.com/t/limit-connection/206528/5 "2011-05-05T00:21:08Z")

</div>

Hi Chris,  
I want to control the public to do query inside my website, so that bad  
guy can not do database harvest.  
For example, each IP can only do query 10 times per day.

The IP I do not want to limit is my own IP. So it’s simple to recognize  
the IP range.

Please let me know your opinion.  
Thanks,  
Yanxin

---

<div class="post-metadata">

**Author:** ![yanxin\_z](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/d6d6ee/32.png) [@yanxin\_z](https://www.ruby-forum.com/u/yanxin_z)\
**Post date:** [May 5, 2011, 4:27am UTC](https://www.ruby-forum.com/t/limit-connection/206528/6 "2011-05-05T04:27:50Z")

</div>

Thank you for your direction, Chris.

---

<div class="post-metadata">

**Author:** ![yanxin\_z](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/d6d6ee/32.png) [@yanxin\_z](https://www.ruby-forum.com/u/yanxin_z)\
**Post date:** [May 5, 2011, 12:25am UTC](https://www.ruby-forum.com/t/limit-connection/206528/7 "2011-05-05T00:25:50Z")

</div>

[http://www.shanestillwell.com/blog/2009/03/24/throttle-traffic-iptables](http://www.shanestillwell.com/blog/2009/03/24/throttle-traffic-iptables)

I wish you luck on a solution but it seems rather odd

On 5/4/11, Yanxin Z. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Yanxin
> 
> –  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).
> 
> * * *
> 
> nginx mailing list  
> [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> [mailman.nginx.org archive](http://nginx.org/mailman/listinfo/nginx)

–  
–C

“The dumber people think you are, the more surprised they’re going to  
be when you kill them.” - Sir William Clayton
