# I cant use limit\_conn\_zone

**URL:** <https://www.ruby-forum.com/t/i-cant-use-limit-conn-zone/230857>\
**Category:** NGINX\
**Created:** [July 8, 2014, 10:05pm UTC](https://www.ruby-forum.com/t/i-cant-use-limit-conn-zone/230857 "2014-07-08T22:05:55Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![addis\_a](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/c4cdca/32.png) [@addis\_a](https://www.ruby-forum.com/u/addis_a)\
**Post date:** [July 8, 2014, 10:05pm UTC](https://www.ruby-forum.com/t/i-cant-use-limit-conn-zone/230857/1 "2014-07-08T22:05:55Z")

</div>

I want to add some code to my nginx.conf , im using portable nginx php  
mysql  
dev stack (WT-NMP). Anyway when i add " limit\_req\_zone  
$binary\_remote\_addr  
zone=one:10m rate=1r/s; " in http {… , nginx is not working  
correctly.  
where do i go wrong, i need help. Thanks in advance

Posted at Nginx Forum:

> **[i cant use limit\_conn\_zone](https://forum.nginx.org/read.php?2,251561,251561#msg-251561)**
>
> I want to add some code to my nginx.conf , im using portable nginx php mysql dev stack (WT-NMP). Anyway when i add " limit\_req\_zone $binary\_remote\_addr zone=one:10m rate=1r/s; " in http {.. , nginx is not working correctly. where do i go...

---

<div class="post-metadata">

**Author:** ![farukest](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/e9bcb4/32.png) [@farukest](https://www.ruby-forum.com/u/farukest)\
**Post date:** [July 8, 2014, 10:44pm UTC](https://www.ruby-forum.com/t/i-cant-use-limit-conn-zone/230857/2 "2014-07-08T22:44:00Z")

</div>

This version from here [http://nginx-win.ecsds.eu/](http://nginx-win.ecsds.eu/) works with shared  
memory.

Posted at Nginx Forum:

> **[Re: i cant use limit\_conn\_zone](https://forum.nginx.org/read.php?2,251561,251565#msg-251565)**
>
> I want to add some code to my nginx.conf , im using portable nginx php mysql dev stack (WT-NMP). Anyway when i add " limit\_req\_zone $binary\_remote\_addr zone=one:10m rate=1r/s; " in http {.. , nginx is not working correctly. where do i go...

---

<div class="post-metadata">

**Author:** ![farukest](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/e9bcb4/32.png) [@farukest](https://www.ruby-forum.com/u/farukest)\
**Post date:** [July 8, 2014, 10:58pm UTC](https://www.ruby-forum.com/t/i-cant-use-limit-conn-zone/230857/3 "2014-07-08T22:58:18Z")

</div>

Thank your for your care but i dont understand which documentation shoul  
i  
read ? i entered [http://nginx-win.ecsds.eu/](http://nginx-win.ecsds.eu/) works but i could not find  
the  
documentation about limiting. Can you give me more information. I need  
help.

Posted at Nginx Forum:

> **[Re: i cant use limit\_conn\_zone](https://forum.nginx.org/read.php?2,251561,251566#msg-251566)**
>
> I want to add some code to my nginx.conf , im using portable nginx php mysql dev stack (WT-NMP). Anyway when i add " limit\_req\_zone $binary\_remote\_addr zone=one:10m rate=1r/s; " in http {.. , nginx is not working correctly. where do i go...

---

<div class="post-metadata">

**Author:** ![farukest](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/e9bcb4/32.png) [@farukest](https://www.ruby-forum.com/u/farukest)\
**Post date:** [July 8, 2014, 11:28pm UTC](https://www.ruby-forum.com/t/i-cant-use-limit-conn-zone/230857/4 "2014-07-08T23:28:04Z")

</div>

First of all i should say , my english not so good… And now my website  
is  
underattack. I have to limit.  
I’m using WT-NMP to use nginx php and mysql so i should use some code in  
nginx.conf. E.g I’m using “limit\_rate 700k” . But i dont understand what  
should i do, Please give me more information… or example. Thank you for  
your patience 🙂

Posted at Nginx Forum:

> **[Re: i cant use limit\_conn\_zone](https://forum.nginx.org/read.php?2,251561,251568#msg-251568)**
>
> I want to add some code to my nginx.conf , im using portable nginx php mysql dev stack (WT-NMP). Anyway when i add " limit\_req\_zone $binary\_remote\_addr zone=one:10m rate=1r/s; " in http {.. , nginx is not working correctly. where do i go...

---

<div class="post-metadata">

**Author:** ![farukest](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/e9bcb4/32.png) [@farukest](https://www.ruby-forum.com/u/farukest)\
**Post date:** [July 8, 2014, 11:11pm UTC](https://www.ruby-forum.com/t/i-cant-use-limit-conn-zone/230857/5 "2014-07-08T23:11:24Z")

</div>

This has nothing to do with documentation, what you want to use does not  
work with the original nginx version (shared memory) the version on the  
website I’ve referred you to does work, so either forget about using  
limit\_conn\_zone or replace your nginx version with this other version.

Posted at Nginx Forum:

> **[Re: i cant use limit\_conn\_zone](https://forum.nginx.org/read.php?2,251561,251567#msg-251567)**
>
> I want to add some code to my nginx.conf , im using portable nginx php mysql dev stack (WT-NMP). Anyway when i add " limit\_req\_zone $binary\_remote\_addr zone=one:10m rate=1r/s; " in http {.. , nginx is not working correctly. where do i go...

---

<div class="post-metadata">

**Author:** ![farukest](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/e9bcb4/32.png) [@farukest](https://www.ruby-forum.com/u/farukest)\
**Post date:** [July 9, 2014, 12:02am UTC](https://www.ruby-forum.com/t/i-cant-use-limit-conn-zone/230857/6 "2014-07-09T00:02:00Z")

</div>

Hello!

On Tue, Jul 08, 2014 at 04:05:26PM -0400, farukest wrote:

> I want to add some code to my nginx.conf , im using portable nginx php mysql  
> dev stack (WT-NMP). Anyway when i add " limit\_req\_zone $binary\_remote\_addr  
> zone=one:10m rate=1r/s; " in http {.. , nginx is not working correctly.  
> where do i go wrong, i need help. Thanks in advance

The “limit\_conn\_zone” creates a shared memory zone, and this  
doesn’t work on Windows Vista and later due to ASLR, see here:

> **[nginx for Windows](http://nginx.org/en/docs/windows.html#known_issues)**
>
> Version of nginx for Windows uses the native Win32 API (not the Cygwin emulation layer). Only the select() and poll() (1.15.9) connection processing methods are currently used, so high performance and scalability should not be expected. Due to this...

One of possible workarounds is to start nginx with “master\_process  
off”, which is mostly development mode, though also allows to  
address this limitation.

–  
Maxim D.

> **[nginx](http://nginx.org/)**

---

<div class="post-metadata">

**Author:** ![farukest](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/e9bcb4/32.png) [@farukest](https://www.ruby-forum.com/u/farukest)\
**Post date:** [July 9, 2014, 12:51am UTC](https://www.ruby-forum.com/t/i-cant-use-limit-conn-zone/230857/7 "2014-07-09T00:51:59Z")

</div>

By the way i read this document. It says you should never use nginx in  
“master\_process off” mode.

[http://nginx.org/en/docs/faq/daemon\_master\_process\_off.html](http://nginx.org/en/docs/faq/daemon_master_process_off.html)

Posted at Nginx Forum:

> **[Re: i cant use limit\_conn\_zone](https://forum.nginx.org/read.php?2,251561,251573#msg-251573)**
>
> I want to add some code to my nginx.conf , im using portable nginx php mysql dev stack (WT-NMP). Anyway when i add " limit\_req\_zone $binary\_remote\_addr zone=one:10m rate=1r/s; " in http {.. , nginx is not working correctly. where do i go...

---

<div class="post-metadata">

**Author:** ![farukest](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/e9bcb4/32.png) [@farukest](https://www.ruby-forum.com/u/farukest)\
**Post date:** [July 9, 2014, 12:49am UTC](https://www.ruby-forum.com/t/i-cant-use-limit-conn-zone/230857/8 "2014-07-09T00:49:01Z")

</div>

Thank you for your information. I understood what you are explaining  
about.  
But i heard for the first time, what is the “master\_process  
off” mode. How can i use it with nignx (By the way i’m using portable  
nginx,php,mysql windows app). I really need help. Thanks is advance.

Posted at Nginx Forum:

> **[Re: i cant use limit\_conn\_zone](https://forum.nginx.org/read.php?2,251561,251572#msg-251572)**
>
> I want to add some code to my nginx.conf , im using portable nginx php mysql dev stack (WT-NMP). Anyway when i add " limit\_req\_zone $binary\_remote\_addr zone=one:10m rate=1r/s; " in http {.. , nginx is not working correctly. where do i go...

---

<div class="post-metadata">

**Author:** ![farukest](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/e9bcb4/32.png) [@farukest](https://www.ruby-forum.com/u/farukest)\
**Post date:** [July 9, 2014, 2:52am UTC](https://www.ruby-forum.com/t/i-cant-use-limit-conn-zone/230857/9 "2014-07-09T02:52:49Z")

</div>

Hello!

On Tue, Jul 08, 2014 at 06:48:47PM -0400, farukest wrote:

> Thank you for your information. I understood what you are explaining about.  
> But i heard for the first time, what is the “master\_process  
> off” mode. How can i use it with nignx (By the way i’m using portable  
> nginx,php,mysql windows app). I really need help. Thanks is advance.

> **[Core functionality](http://nginx.org/en/docs/ngx_core_module.html#master_process)**
>
> Determines whether worker processes are started. This directive is intended for nginx developers.

Just add the directive to nginx.conf at global level.

Switching off master process means that separate master process  
won’t be used, and the only process started will do all the work.  
This implies various limitations (e.g., no auto respawn of dead  
processes, configuration reload won’t work and so on), but also  
simplifies debugging. (And it also happens to work around the  
problem with shared memory on Windows.)

–  
Maxim D.

> **[nginx](http://nginx.org/)**

---

<div class="post-metadata">

**Author:** ![farukest](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/e9bcb4/32.png) [@farukest](https://www.ruby-forum.com/u/farukest)\
**Post date:** [July 9, 2014, 2:55am UTC](https://www.ruby-forum.com/t/i-cant-use-limit-conn-zone/230857/10 "2014-07-09T02:55:12Z")

</div>

Hello!

On Tue, Jul 08, 2014 at 06:51:46PM -0400, farukest wrote:

> By the way i read this document. It says you should never use nginx in  
> “master\_process off” mode.
> 
> [Can I run nginx with “daemon off” or “master\_process off” settings in a production environment?](http://nginx.org/en/docs/faq/daemon_master_process_off.html)

You should never run production on Windows anyway. If you are  
going to use it for production, not for development, it’s much  
better idea to change the OS in the first place.

–  
Maxim D.

> **[nginx](http://nginx.org/)**

---

<div class="post-metadata">

**Author:** ![farukest](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/e9bcb4/32.png) [@farukest](https://www.ruby-forum.com/u/farukest)\
**Post date:** [July 9, 2014, 3:13am UTC](https://www.ruby-forum.com/t/i-cant-use-limit-conn-zone/230857/11 "2014-07-09T03:13:03Z")

</div>

Thank you for your care, yes I know but i have to use windows… I added  
“master\_process on;” to global level. There is not any problem from  
here.  
now how does it allow me to limit connection per ip ?

Posted at Nginx Forum:

> **[Re: i cant use limit\_conn\_zone](https://forum.nginx.org/read.php?2,251561,251577#msg-251577)**
>
> I want to add some code to my nginx.conf , im using portable nginx php mysql dev stack (WT-NMP). Anyway when i add " limit\_req\_zone $binary\_remote\_addr zone=one:10m rate=1r/s; " in http {.. , nginx is not working correctly. where do i go...

---

<div class="post-metadata">

**Author:** ![farukest](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/e9bcb4/32.png) [@farukest](https://www.ruby-forum.com/u/farukest)\
**Post date:** [July 9, 2014, 3:57am UTC](https://www.ruby-forum.com/t/i-cant-use-limit-conn-zone/230857/12 "2014-07-09T03:57:11Z")

</div>

Thank you i did what you said and it is working good. does this process  
slow  
down the website ? If it does, what should i do for as an alternative  
speed.  
Any idea ?

Posted at Nginx Forum:

> **[Re: i cant use limit\_conn\_zone](https://forum.nginx.org/read.php?2,251561,251590#msg-251590)**
>
> I want to add some code to my nginx.conf , im using portable nginx php mysql dev stack (WT-NMP). Anyway when i add " limit\_req\_zone $binary\_remote\_addr zone=one:10m rate=1r/s; " in http {.. , nginx is not working correctly. where do i go...

---

<div class="post-metadata">

**Author:** ![farukest](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/e9bcb4/32.png) [@farukest](https://www.ruby-forum.com/u/farukest)\
**Post date:** [July 9, 2014, 3:22am UTC](https://www.ruby-forum.com/t/i-cant-use-limit-conn-zone/230857/13 "2014-07-09T03:22:39Z")

</div>

Hello!

On Tue, Jul 08, 2014 at 09:12:19PM -0400, farukest wrote:

> Thank you for your care, yes I know but i have to use windows.. I added  
> “master\_process on;” to global level. There is not any problem from here.  
> now how does it allow me to limit connection per ip ?

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

–  
Maxim D.

> **[nginx](http://nginx.org/)**

---

<div class="post-metadata">

**Author:** ![farukest](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/e9bcb4/32.png) [@farukest](https://www.ruby-forum.com/u/farukest)\
**Post date:** [July 9, 2014, 4:04am UTC](https://www.ruby-forum.com/t/i-cant-use-limit-conn-zone/230857/14 "2014-07-09T04:04:19Z")

</div>

Hello!

On Tue, Jul 08, 2014 at 09:56:52PM -0400, farukest wrote:

> Thank you i did what you said and it is working good. does this process slow  
> down the website ? If it does, what should i do for as an alternative speed.  
> Any idea ?

You may want to actually read the link provided. It explains how  
to configure limit\_conn, what it does and what will be the  
expected result. Quoting most relevant part of the limit\_conn  
directive docs ([Module ngx\_http\_limit\_conn\_module](http://nginx.org/r/limit_conn)):

: Sets the shared memory zone and the maximum allowed number of  
: connections for a given key value. When this limit is exceeded,  
: the server will return the 503 (Service Temporarily Unavailable)  
: error in reply to a request. For example, the directives  
:  
: limit\_conn\_zone $binary\_remote\_addr zone=addr:10m;  
:  
: server {  
: location /download/ {  
: limit\_conn addr 1;  
: }  
:  
: allow only one connection per an IP address at a time.

–  
Maxim D.

> **[nginx](http://nginx.org/)**

---

<div class="post-metadata">

**Author:** ![farukest](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/e9bcb4/32.png) [@farukest](https://www.ruby-forum.com/u/farukest)\
**Post date:** [July 9, 2014, 12:20pm UTC](https://www.ruby-forum.com/t/i-cant-use-limit-conn-zone/230857/15 "2014-07-09T12:20:33Z")

</div>

Thank you for your care. It works like a charm. But sometimes page is  
not  
loading correctly. what is the logic of “zone=addr:10m;” and i want to  
block  
website entering (fast entering) and last question what location should  
i  
define for “wp-content/uploads/somevideo.mp4” per ip. Thanks in advance  
your  
help is really important for me

Posted at Nginx Forum:

> **[Re: i cant use limit\_conn\_zone](https://forum.nginx.org/read.php?2,251561,251605#msg-251605)**
>
> I want to add some code to my nginx.conf , im using portable nginx php mysql dev stack (WT-NMP). Anyway when i add " limit\_req\_zone $binary\_remote\_addr zone=one:10m rate=1r/s; " in http {.. , nginx is not working correctly. where do i go...

---

<div class="post-metadata">

**Author:** ![farukest](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/e9bcb4/32.png) [@farukest](https://www.ruby-forum.com/u/farukest)\
**Post date:** [July 9, 2014, 1:28pm UTC](https://www.ruby-forum.com/t/i-cant-use-limit-conn-zone/230857/16 "2014-07-09T13:28:29Z")

</div>

I realized now, master process off is not enough to playing HD movies.  
It  
gives error after a while. But i want to thank you because making block  
for  
a while, using master process and limit\_conn destroyed the attacking.  
Now i  
turn my nginx.conf to master\_process on. Everything is alright. Thank  
you  
again.

Posted at Nginx Forum:

> **[Re: i cant use limit\_conn\_zone](https://forum.nginx.org/read.php?2,251561,251606#msg-251606)**
>
> I want to add some code to my nginx.conf , im using portable nginx php mysql dev stack (WT-NMP). Anyway when i add " limit\_req\_zone $binary\_remote\_addr zone=one:10m rate=1r/s; " in http {.. , nginx is not working correctly. where do i go...
