proxy_limit_rate

Controls the rate at which responses are sent to clients when using the proxy module. — NGINX HTTP Core

proxy_limit_rate
httpserverlocation
Синтаксисproxy_limit_rate rate;
По умолчаниюnone
Контекстhttp, server, location
МодульNGINX HTTP Core
Аргументы1

Описание

The `proxy_limit_rate` directive sets a limit on the response rate for proxied connections, allowing you to control the bandwidth usage for certain requests. This directive is particularly useful for restricting how much data is sent to a client from a proxied server on the back end, thereby preventing a client from overwhelming the server or consuming too much bandwidth. The rate can be defined with the syntax that supports size units similar to other NGINX directives, such as 'k' or 'm' for kilobytes or megabytes respectively. The limit is imposed on a per-connection basis, meaning that the directive controls the maximum bandwidth per individual connection instead of the overall bandwidth. By using this directive within the context of `http`, `server`, or `location`, you can ensure that clients receive responses at a steady and controlled pace, which can improve overall response times and user experience on your applications, especially those dealing with large file downloads or heavy data processing. Note that setting this directive does not limit the total bandwidth consumed by all clients; each connection will still be limited as specified, but collectively they may consume significant bandwidth if many clients are connected.

Пример конфига

location /download {
    proxy_pass http://backend;
    proxy_limit_rate 100k;  # Limits the response rate to 100 kilobytes per second
}

Setting a strict limit may lead to clients experiencing slow download speeds, especially over high-latency connections.

This directive only applies to proxied connections; it does not affect direct connections to the NGINX server.

Make sure to test your configurations, as combining this with other rate control directives can lead to unexpected results.