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

Nginx Requirements

  1. 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.

  2. 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

  1. Install the module as usual from drupal.org.

  2. Add the support for the upload progress bar in your nginx configuration.

  3. Done.

Nginx configuration

The configuration consists in three parts:

  1. 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.

  2. 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;
    }
  3. 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;
    }
  4. Reload your nginx configuration:

    service nginx reload
  5. Done.

TODO

  1. 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

Downloads