Answer the question
In order to leave comments, you need to log in
How to dynamically limit download speed in nginx?
Good afternoon.
I read an article about speed limiting and the following question arose - is it possible to change the speed dynamically through arg parameters?
I try this, but I get an error in the config.
location ~ ^/play/.*\.mp3$ {
rewrite ^/play/(.*)$ /$1 break;
if ($args ~ speed=(.+)) {
limit_speed one $arg_speed;
}
root /var/www;
}
You know about the X-Accel-Limit-Rate header, but it doesn't work that way.
I still see the option to generate the nginx config and re-read it.
Answer the question
In order to leave comments, you need to log in
What if you read the documentation ?
The rate limit can also be set in the $limit_rate variable. This can be useful in cases where the speed needs to be limited depending on some condition:server { if ($slow) { set $limit_rate 4k; } ... }
It not that - looked the documentation.
$limit_rate The limit is set per request, so if the client opens two connections at the same time, the total rate will be twice the limit.
I need to use the nginx_limit_speed_module module so that the limit works for ip, and not for the connection. Question - how to dynamically change the parameter?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question