upload_progress
The 'upload_progress' directive tracks the progress of file uploads in NGINX, allowing clients to monitor their upload status.
Description
The 'upload_progress' directive is utilized to enable upload progress tracking in NGINX by allocating shared memory for storing per-connection tracking information. It is particularly useful during file uploads as it provides real-time statistics to the client through a web API via unique identifiers. Each upload request must contain a unique identifier (either as a GET parameter or as an HTTP header), ensuring that the uploaded data can be referenced accurately when reporting progress.
This directive requires two arguments: <zone_name>, which designates the name of the shared memory zone to be used for storing upload progress data, and <zone_size>, which specifies the size of this memory zone in bytes. Once defined, NGINX will use this zone to maintain statistics related to each upload, including the current state, remaining bytes, total length, and other critical metrics. To maximize efficiency and reduce memory usage, it's important to configure the zone size adequately based on expected concurrent uploads.
In conjunction with the 'track_uploads' directive, which enables tracking for POST requests directed at a specific location, 'upload_progress' effectively monitors uploads without parsing the uploaded content, making it a powerful tool for managing file uploads in environments where progress reporting is desired, such as applications that involve large file transfers or video uploads.
Config Example
upload_progress uploads 1m;
Ensure the zone size is sufficient to handle concurrent uploads; insufficient size might lead to data loss or overwrites.
Each upload request must contain a unique identifier; otherwise, tracking cannot occur.
When using with certain locations, ensure that responses are correctly configured to avoid conflicts with other directives.