Limitting connection Per ip
Posted: Fri Apr 29, 2016 8:34 am
Hi , I would like to limit the number of connections that each IP can make to my server.
How can i do this with vestacp?
Thanks
How can i do this with vestacp?
Thanks
Code: Select all
nano /etc/nginx/conf.d/limits.conf
Code: Select all
limit_conn_zone $binary_remote_addr zone=pip:10m;
limit_req_zone $binary_remote_addr zone=prs:10m rate=1r/s;
Code: Select all
limit_conn pip 3;
limit_conn_status 503;
limit_req zone=prs burst=35 nodelay;
Code: Select all
nginx -t
service nginx restart
Thank you very much for your reply.skurudo wrote:With nginx you can do it.
[/code]
In this example nginx show status 503 (Service Unavailable), but you can drop connection via 444 status.Hnaseri wrote: Lets say we have assigned n as the maximum number of connections. If an ip tries to make n+1 connections, does this code drops the extra connection? Or it simply blocks the entire n+1 connections?
Code: Select all
limit_conn pip 3;
Sorry, hardly believe that.violajsilver wrote:Thank you very much for the post. I was exactly searching for the same thread.
So you're saying that the following code will drop extra connections?skurudo wrote:
In this example nginx show status 503 (Service Unavailable), but you can drop connection via 444 status.
Code: Select all
limit_conn_status 444;
I'm and nginx documentation/examples ;-)Hnaseri wrote: So you're saying that the following code will drop extra connections?Code: Select all
limit_conn_status 444;
http://nginx.org/en/docs/http/ngx_http_ ... tml#returnStops processing and returns the specified code to a client. The non-standard code 444 closes a connection without sending a response header.
thank you very much for your reply.skurudo wrote:
I'm and nginx documentation/examples ;-)