max_ranges

The 'max_ranges' directive limits the number of HTTP range requests that an NGINX server will process for a single response.

Syntaxmax_ranges number;
Defaultnone
Contexthttp, server, location
Arguments1

Description

The max_ranges directive in NGINX is used to control the maximum number of range requests the server will honor in a single HTTP response. A range request allows clients to request specific parts of a resource, which is useful for resuming downloads or streaming media content. By limiting the number of ranges that can be requested, server resources can be preserved, and the performance impact of complex range requests can be mitigated.

The directive is defined in the http, server, and location contexts, making it versatile for various configuration scenarios. When a client sends a request with multiple ranges that exceeds the specified number set by max_ranges, NGINX will respond with an HTTP error indicating that the request cannot be fulfilled. This helps prevent potential denial of service attacks through excessive range requests and improves server stability under load.

The parameter for max_ranges is an integer that denotes the maximum number of accepted ranges. For instance, if set to 5, the server will only process up to 5 range requests at a time and reject any more. This configuration can be particularly significant for media servers or applications serving large files, where clients might attempt to request extensive byte ranges simultaneously, leading to increased overhead.

Config Example

http {
    max_ranges 4;
}

Setting this value too low may lead to issues where clients cannot retrieve large files effectively.

Overly high values can strain server resources, especially under heavy load.

← Back to all directives