Welcome! Log In Create A New Profile

Advanced

How to limit connections per ip for every virtual host? My config is not working

Posted by gonguinguen 
I'm relative new to nginx, so maybe I'm missinterpreting the documentation.
I have multiple websites served by nginx, each one in its own domain.
I would like to apply a maximum number of connnections that a single ip can open **to each domain**.
This is the configuration I have now:


http {
limit_conn_zone $binary_remote_addr zone=perip:10m;

server {
server_name website1.com;
limit_conn perip 5; }

server {
server_name website2.com;
limit_conn perip 5; }

server {
server_name website3.com;
limit_conn perip 5; }
}


Consider that configuration for a lot of websites (around 100).
The problem is this: when I open several of those websites in different tabs in my browser, some of them return 503.
It seems as if the limit_conn is applied for each ip, regardless the virtual server to wich it's connected, that is, regardless the server block directive where it's applied. The documentation says that the context of the directive is http, server and location. So I though it would have to work that way.

Could it work if I declare a different connection zone for every domain? That's the only alternative I could think about, but I'm not sure, maybe I'm missinterpreting something.

I'll appreciate any clarification on this.
Thanks in advance!
Regards, Lisandro.
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 137
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready