Filefield Nginx Progress
Introduction
This module provides support for an upload progress bar for a backend/server implementing the RFC 1867 upload using multipart/form-data. Nginx does not yet support RFC 1867 uploads in
its suite of official modules. You can use the Upload 3rd party module to do that or just rely on PHP FastCGI support for RFC 1867.
Drupal Requirements
-
For drupal 6 the filefield module must be installed.
-
For drupal 7 the file field is now a core module and must be enabled.
Nginx Requirements
-
Using Nginx with a FastCGI backend, making use of the FastCGI module with the
PHP backend. or using Nginx as a reverse proxy, making use of the Proxy module. -
Use the 3rd party Upload Progress Nginx module.
Build instructions are here.
Verify that the upload progress module is installed by issuing:
nginx -V
and check if there's a line with
--add-module=path/to/nginx-upload-progress-module
. If there is that means that the support for the upload progress bar is compiled in. Now you need to support the upload progress bar in the Nginx configuration.
Instalation
-
Install the module as usual from drupal.org.
-
Add the support for the upload progress bar in your nginx configuration.
-
Done.
Nginx configuration
The configuration consists in three parts:
-
Add a zone for tracking the uploads. This is a memory block used for storing the information regarding the upload that Nginx is proxying.
## Define a zone named uploads with a 1MB size. upload_progress uploads 1m;
This is to be done at the
http
level of your config, meaning that it's the same for all vhosts configured on an instance of Nginx. -
Do a rewrite to support the way that the Nginx module reports the progress.
## The Nginx module wants ?X-Progress-ID query parameter so ## that it report the progress of the upload through a GET ## request. But the drupal form element makes use of clean ## URLs in the POST. ## Drupal 7 config. location ~ (?<upload_form_uri>.*)/x-progress-id:(?<upload_id>\d*) { rewrite ^ $upload_form_uri?X-Progress-ID=$upload_id; } ## Now the above rewrite must be matched by a location that ## activates it and references the above defined upload ## tracking zone. location ^~ /progress { upload_progress_json_output; report_uploads uploads; } ## Drupal 6 config. location ~ (?<upload_form_uri>.*)/x-progress-id:(?<upload_id>\w*) { rewrite ^ $upload_form_uri?X-Progress-ID=$upload_id; } ## Now the above rewrite must be matched by a location that ## activates it and references the above defined upload ## tracking zone. location ^~ /progress { ## Comment out the line below if you're using a version ## of the Nginx Upload Progress module less than 0.9.0. upload_progress_java_output; # this for version 0.9.0 of the module report_uploads uploads; }
-
Now on each location where you want the upload progress bar to work you must enable it like on this example.
N.B. The
track_uploads
directive must be the last in a given location.location = /index.php { include fastcgi.conf; fastcgi_pass phpcgi; ## Track uploads for this location on the zone defined ## above with a 60 seconds timeout. track_uploads uploads 60s; }
-
Reload your nginx configuration:
service nginx reload
-
Done.
TODO
- Suggest a configuration and verify it using a
hook_requirements()
.
Credits & Acknowledgments
This module development is done by smoothify sponsored by the Spirit Library and perusio — focusing on the D7 version.
Project information
- Module categories: Content Editing Experience, Media
- 112 sites report using this module
- Created by smoothify on , updated
- Stable releases for this project are covered by the security advisory policy.
Look for the shield icon below.
Releases
Development version: 7.x-2.x-dev updated 21 Jul 2011 at 00:12 UTC