masterzen / nginx-upload-progress-module

Nginx module implementing an upload progress system, that monitors RFC1867 POST uploads as they are transmitted to upstream servers.
http://wiki.codemongers.com/NginxHttpUploadProgressModule
Other
432 stars 101 forks source link

Nginx Upload Progress Module

Introduction

nginx_uploadprogress_module is an implementation of an upload progress system, that monitors RFC1867 POST upload as they are transmitted to upstream servers.

It works by tracking the uploads proxied by Nginx to upstream servers without analysing the uploaded content and offers a web API to report upload progress in Javscript, Json or any other format (through the help of templates).

It works because Nginx acts as an accelerator of an upstream server, storing uploaded POST content on disk, before transmitting it to the upstream server. Each individual POST upload request should contain a progress unique identifier.

This module is Copyright (c) 2007-2012 Brice Figureau, and is licensed under the BSD license (see LICENSE).

The JSON idea and the mechanism idea are based on Lighttpd mod_uploadprogress: http://blog.lighttpd.net/articles/2006/08/01/mod_uploadprogress-is-back

WARNING:

INCOMPATIBLE CHANGES

v0.9.0:

JSONP is now the default output of the progress probes. If you rely on this module serving the deprecated java output use: upload_progress_java_output in the progress probe location.

Installation

nginx_uploadprogress_module has been tested with Nginx 0.6.x, 0.7.x, 0.8.x and 1.0.x.

Download the Nginx sources from http://nginx.net/ and unpack it.

To build Nginx, change to the directory which contains the Nginx sources, and run the configuration script making sure to add the path to the nginx_uploadprogress_module sources using the --add-module option: ::

$ ./configure --add-module=/path/to/nginx_uploadprogress_module/

Now you can build and install the software:

$ make

and as root:

$ make install

Configuration

Each upload request should be assigned a unique identifier. This unique identifier will be used to store the request and reference it to report. This identifier can be transmitted either as a GET argument or as an HTTP header whose name is X-Progress-ID.

upload_progress +++++++++++++++ :Syntax: upload_progress :Default: none :Context: http :Description: This directive enables the upload progress module and reserve bytes to the which will be used to store the per-connection tracking information.

track_uploads +++++++++++++ :Syntax: track_uploads :Default: none :Context: location :Description: This directive enables tracking uploads for the current location. Each POST landing in this location will register the request in the upload progress tracker. Since Nginx doesn't support yet RFC 1867 upload, the location must be a proxy_pass or fastcgi location. The POST must have a query parameter called X-Progress-ID (or an HTTP header of the same name) whose value is the unique identifier used to get progress information. If the POST has no such information, the upload will not be tracked. The tracked connections are kept at most seconds after they have been finished to be able to serve useful information to upload progress probes. WARNING: this directive must be the last directive of the location. It must be in a proxy_pass or fastcgi_pass location.

report_uploads ++++++++++++++ :Syntax: report_uploads :Default: none :Context: location :Description: This directive allows a location to report the upload progress that is tracked by track_uploads for . The returned document is a Javascript text with the possible 4 results by default:

upload_progress_content_type ++++++++++++++++++++++++++++ :Syntax: upload_progress_content_type :Default: text/javascript :Context: location :Description: This directive allows to change the upload progress probe response content-type.

upload_progress_header ++++++++++++++++++++++ :Syntax: upload_progress_header :Default: X-Progress-ID :Context: location :Description: This directive allows to change the header name of the progress ID.

upload_progress_jsonp_parameter ++++++++++++++++++++++ :Syntax: upload_progress_jsonp_parameter :Default: callback :Context: location :Description: This directive allows to change the name of the GET parameter with the jsonp callback name.

upload_progress_java_output +++++++++++++++++++++++++++ :Syntax: upload_progress_java_output :Default: N/A :Context: location :Description: This directive sets everything to output as eval() javascript compatible code.

upload_progress_json_output +++++++++++++++++++++++++++ :Syntax: upload_progress_json_output :Default: N/A :Context: location :Description: This directive sets everything to output as pure json.

upload_progress_jsonp_output ++++++++++++++++++++++++++++ :Syntax: upload_progress_jsonp_output :Default: N/A :Context: location :Description: This directive sets everything to output as jsonp (like json output, but with callback).

upload_progress_template ++++++++++++++++++++++++ :Syntax: upload_progress_template