fastcgi_force_ranges

The `fastcgi_force_ranges` directive forces the FastCGI server to respond to byte range requests with a 206 Partial Content status.

Syntaxfastcgi_force_ranges on | off;
Defaultoff
Contexthttp, server, location
Argumentsflag

Description

The fastcgi_force_ranges directive is utilized within NGINX to handle byte range requests that are sent to a FastCGI backend. By default, some FastCGI applications may not properly support byte ranges, resulting in incorrect content delivery for partial requests. When this directive is enabled (set to 'on'), NGINX will ensure that byte-range requests are properly interpreted and handled by the FastCGI server, forcing it to respond with a 206 Partial Content response, provided that the specified range is valid.

In practical terms, this directive is particularly important for serving video or audio content over HTTP, where clients may request specific byte ranges for streaming functionality. By instructing the FastCGI server to acknowledge these byte-range requests, NGINX improves compatibility and content delivery efficiency. The directive can be applied globally, or within specific server and location contexts, making it flexible for various website configurations.

The fastcgi_force_ranges directive accepts a flag: it can be set to 'on' or 'off', with 'off' disabling the forced response behavior. When enabled, NGINX interacts directly with the FastCGI server to negotiate and manage byte ranges, ensuring clients receive the appropriate segments of data they request. This behavior enhances the end-user experience, particularly for media-rich applications.

Config Example

server {
    location /api {
        fastcgi_pass backend;
        fastcgi_force_ranges on;
    }
}

Ensure that the FastCGI server supports range requests, as not all servers implement this functionality correctly.

Using this directive indiscriminately might lead to unintended consequences, like increased server load from improperly processed requests.

← Back to all directives