M
M
Magic_Moment2021-09-09 12:10:45
linux
Magic_Moment, 2021-09-09 12:10:45

How to limit the total speed for All connections for 1 IP in NGINX?

Hello.
Need to limit total file download speed to 1 IP on NGINX server.
Right now I'm using limit_rate in the main nginx.conf config file in http context and this solution works for me, but only partially:
http{
limit rate 120k;
}
If you open many tabs and start downloading many files at the same time, then the overall download speed will increase by a multiple of the number of downloaded files. And that's not what I would like.

It seems to me that this solution, with the addition of limit_conn_zone, is not bad, but for some reason it does not work. But it has not yet been possible to make friends with the assembly of NGINX packages to install the limit_speed_zone module.

I also tried to limit not the speed, but the number of simultaneous connections per 1 IP, so that more than N files could not be downloaded at the same time. The solution described here did not work for me. Perhaps because files are loaded via a GET parameter like /load.php?file= , and the module processes only static requests (not GET (but maybe I'm wrong)).

Who can throw ideas, how else can I configure the server by setting the necessary restrictions?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Magic_Moment, 2021-10-14
@Magic_Moment

In general, it may be useful to someone. I lowered my download speed to 120kb/s with
http{
limit rate 120k;
}
, which I hope will discourage anyone from downloading files from the site at such a speed. While I use this method, tk. couldn't find better :)

K
ky0, 2021-09-09
@ky0

What you want to do is not on a web server, but on a firewall that touches network packets directly.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question