# Add limit\_upstream to nginx

**URL:** <https://www.ruby-forum.com/t/add-limit-upstream-to-nginx/244797>\
**Category:** NGINX\
**Created:** [June 16, 2016, 6:04am UTC](https://www.ruby-forum.com/t/add-limit-upstream-to-nginx/244797 "2016-06-16T06:04:01Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sadaf\_N](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/858c86/32.png) [@Sadaf\_N](https://www.ruby-forum.com/u/Sadaf_N)\
**Post date:** [June 16, 2016, 6:04am UTC](https://www.ruby-forum.com/t/add-limit-upstream-to-nginx/244797/1 "2016-06-16T06:04:01Z")

</div>

I wrote a module for nginx 4 years ago which limited the number of  
connections to upstream in order that the upstream servers would not be  
too  
busy to work efficiently. Now I think this module is stable, and expect  
it  
to be merged into nginx official if possible.

the code is here:  
_[GitHub - cfsego/nginx-limit-upstream: limit the number of connections to upstream for NGINX](https://github.com/cfsego/nginx-limit-upstream)  
 [https://github.com/cfsego/nginx-limit-upstream](https://github.com/cfsego/nginx-limit-upstream)_

sincerely

---

<div class="post-metadata">

**Author:** ![Chuanwen\_Chen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/8dc957/32.png) [@Chuanwen\_Chen](https://www.ruby-forum.com/u/Chuanwen_Chen)\
**Post date:** [June 20, 2016, 2:56pm UTC](https://www.ruby-forum.com/t/add-limit-upstream-to-nginx/244797/2 "2016-06-20T14:56:02Z")

</div>

Hi Chuanwen  
Your module did not quite work for me. I opened up a ticket here.

> <https://github.com/cfsego/nginx-limit-upstream/issues/12>
>
> When compiling with OpenResty 1.9.15.1 there is the following error
> 
> \`\`\`
> 
> /home/…ubuntu/nginx-limit-upstream/ngx\_http\_qos\_module.c: In function ‘ngx\_http\_limit\_upstream\_cleanup’:  
> /home/ubuntu/nginx-limit-upstream/ngx\_http\_qos\_module.c:367:9: warning: implicit declaration of function ‘ngx\_http\_upstream\_connect’ \[-Wimplicit-function-declaration\]  
> ngx\_http\_upstream\_connect(ctx-\>r, ctx-\>r-\>upstream);
> ^
> /home/ubuntu/nginx-limit-upstream/ngx\_http\_qos\_module.c: In function ‘ngx\_http\_limit\_upstream\_get\_peer’:
> /home/ubuntu/nginx-limit-upstream/ngx\_http\_qos\_module.c:411:25: error: ‘ngx\_http\_upstream\_t’ has no member named ‘blocked’  
> if (ctx-\>r-\>upstream-\>blocked) {  
> ^  
> /home/ubuntu/nginx-limit-upstream/ngx\_http\_qos\_module.c:413:25: error: ‘ngx\_http\_upstream\_t’ has no member named ‘blocked’  
> ctx-\>r-\>upstream-\>blocked = 0;
> ^
> /home/ubuntu/nginx-limit-upstream/ngx\_http\_qos\_module.c:607:25: error: ‘ngx\_http\_upstream\_t’ has no member named ‘blocked’
> ctx-\>r-\>upstream-\>blocked = 1;  
> ^  
> /home/ubuntu/nginx-limit-upstream/ngx\_http\_qos\_module.c:609:16: error: ‘NGX\_BLOCK’ undeclared (first use in this function)
> return NGX\_BLOCK;
> ^
> /home/ubuntu/nginx-limit-upstream/ngx\_http\_qos\_module.c:609:16: note: each undeclared identifier is reported only once for each function it appears in
> /home/ubuntu/nginx-limit-upstream/ngx\_http\_qos\_module.c: In function ‘ngx\_http\_limit\_upstream\_init\_peer’:
> /home/ubuntu/nginx-limit-upstream/ngx\_http\_qos\_module.c:684:16: error: ‘ngx\_http\_upstream\_t’ has no member named ‘blocked’
> r-\>upstream-\>blocked = 0;
> ^
> make\[2\]: \*\*\* \[objs/addon/nginx-limit-upstream/ngx\_http\_qos\_module.o\] Error 1
> make\[2\]: \*\*\* Waiting for unfinished jobs....
> make\[2\]: Leaving directory \`/home/ubuntu/openresty/openresty-1.9.15.1/build/nginx-1.9.15'
> make\[1\]: \*\*\* \[build\] Error 2
> make\[1\]: Leaving director
> \`\`\`

Posted at Nginx Forum:

> **[Re: add limit\_upstream to nginx](https://forum.nginx.org/read.php?2,267614,267727#msg-267727)**
>
> I wrote a module for nginx 4 years ago which limited the number of connections to upstream in order that the upstream servers would not be too busy to work efficiently. Now I think this module is stable, and expect it to be merged into nginx official...
