masterzen / nginx-upload-progress-module

Nginx module implementing an upload progress system, that monitors RFC1867 POST uploads as they are transmitted to upstream servers.

Home Page:http://wiki.codemongers.com/NginxHttpUploadProgressModule

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Not working with NginX 0.8.x - 1.0

bkuberek opened this issue · comments

Following Documentation we got it working on 0.7.x. Upgrading to 0.8.x broke progress.

The returned JSON will always look like:

{ "state" : "starting" }

Can you send me privately by e-mail a full debug log of the upload (that requires to compile nginx with the --with-debug option and to setup the error log to debug level).
Also, please include your nginx config (or the relevant parts).
I believe it works fine with nginx 0.8 and 0.9 (but I didn't test 1.0).

Just as a hint - In my setup its working like a charm with 1.0 :)

Ok so it sounds like we have a problem on our end. Thanks for your reply. I will try to find sometime soon and do as requested. Thanks again.

I have just sent you an email. In the email I also mentioned that our Nginx server was recently upgraded to 1.0. Thanks again.

@benbender: It sounds like I may be not be configuring properly. Could you please shed some light and show me how you have done it?

Thanks

Here is an excerpt from the log. (I dont really know what you are looking for in the log but I thought it would save you from searching through the log file I sent you). This I believe to be the log lines while the file was being uploaded:

2011/04/27 16:18:31 [debug] 9892#0: http file cache loader
2011/04/27 16:18:31 [debug] 9892#0: walk tree "/tmp/nginx_proxy"
2011/04/27 16:18:31 [debug] 9892#0: tree name 1:"."
2011/04/27 16:18:31 [debug] 9892#0: tree name 3:"tmp"
2011/04/27 16:18:31 [debug] 9892#0: malloc: 0000000016C62FC0:21
2011/04/27 16:18:31 [debug] 9892#0: tree path "/tmp/nginx_proxy/tmp"
2011/04/27 16:18:31 [debug] 9892#0: tree enter dir "/tmp/nginx_proxy/tmp"
2011/04/27 16:18:31 [debug] 9892#0: walk tree "/tmp/nginx_proxy/tmp"
2011/04/27 16:18:31 [debug] 9892#0: tree name 1:"."
2011/04/27 16:18:31 [debug] 9892#0: tree name 2:".."
2011/04/27 16:18:31 [debug] 9892#0: tree name 2:".."
2011/04/27 16:18:31 [notice] 9892#0: http file cache: /tmp/nginx_proxy 0.000M, bsize: 4096
2011/04/27 16:18:31 [debug] 9890#0: timer delta: 10004
2011/04/27 16:18:31 [debug] 9890#0: event timer del: -1: 1303935511443
2011/04/27 16:18:31 [debug] 9890#0: http file cache expire
2011/04/27 16:18:31 [debug] 9890#0: malloc: 00000000170A7280:55
2011/04/27 16:18:31 [debug] 9890#0: http file cache size: 0
2011/04/27 16:18:31 [debug] 9890#0: event timer add: -1: 10000:1303935521447
2011/04/27 16:18:31 [debug] 9890#0: posted events 0000000000000000
2011/04/27 16:18:31 [debug] 9890#0: epoll timer: 10000
2011/04/27 16:18:31 [notice] 9885#0: signal 17 (SIGCHLD) received
2011/04/27 16:18:31 [notice] 9885#0: cache loader process 9892 exited with code 0
2011/04/27 16:18:31 [debug] 9885#0: wake up, sigio 0

Hmm, i'll give it a try :) I use mod_upload in conjunction with upload_progress module and upload_progress is only a fallback for legacy browsers in my setup. Newer browsers which are supporting the js file-api are handle progressbar completly in js.

The relevant config in nginx looks like this:
http {

...

upload_progress                 proxied 1M;

server {

...

location /upload {
    upload_pass                     @upload_handler;

    upload_store                    /var/uploads/incomplete 1;
    upload_state_store              /var/uploads/incomplete 1;
    upload_resumable                on;
    upload_limit_rate               10M;
    upload_tame_arrays              on;
    upload_pass_args                on;

    upload_add_header               Access-Control-Allow-Origin *;

    upload_store_access             user:rw group:rw all:r;

    upload_aggregate_form_field     count_files                                              "$upload_file_number";
    upload_set_form_field           $upload_field_name[$upload_file_number][name]            "$upload_file_name";
    upload_set_form_field           $upload_field_name[$upload_file_number][mime]            "$upload_content_type";
    upload_set_form_field           $upload_field_name[$upload_file_number][path]            "$upload_tmp_path";
    upload_aggregate_form_field     $upload_field_name[$upload_file_number][md5]             "$upload_file_md5";
    upload_aggregate_form_field     $upload_field_name[$upload_file_number][size]            "$upload_file_size";

    upload_pass_form_field          "^hash|user_id|folder_id|folder_name|upload$";
    upload_cleanup                  400 404 499 500-505;

    upload_progress_header          hash;
    track_uploads                   proxied 30s;
}

location @upload_handler {

handle uploaded file inside a php-script

}

location ^~ /progress {
    report_uploads                  proxied;
    upload_progress_header          hash;
    upload_progress_jsonp_output;
}

}
}

Thanks for the config above. I will compare to mine and see if making changes will get it working. Regarding XHR uploads, I find it a great idea, but in my case it won't work. XHR upload first loads the entire file into memory and sends it to the server as a string. This is ok for some files but not videos and large PDFs.

Thanks again for the help!

Not necessary. You can do sort of chunk uploads with the FileReader-Api. Take a look at:
https://github.com/blueimp/jQuery-File-Upload and the maxFileReaderSize-option.

Hope we'll get you on the right track :)

Very Interesting. One can never know enough. Thank you so much for the link. I will be implementing this in the next version of our app.

I figured it out! Sorry about the trouble.

Here is my mistake: The upload form was passing the X-Progress-ID as one of the form fields. As soon as I removed the hidden field and added X-Progress-ID into the action attribute of the form it worked.

<form id="upload-form-{{id}}" action="/_upload?X-Progress-ID={{id}}" method="post" enctype="multipart/form-data" target="uploadframe-{{id}}">

Thanks again!