3

I set my nginx static content domain like this:

#  static0.mywebsite.com static1.mywebsite.com static2.mywebsite.com static3.mywebsite.com
server {

        # upload limit
        # upload_limit_rate 10240;

        # request size limitation
        client_max_body_size 500m;
        client_body_buffer_size 64k;

        # document root
        root /home/mywebsite/myns-projects/mywebsite_com/static/public/;

        # index file
        index index.php;

        # server name
        server_name  static0.mywebsite.com;

        # rewrite rules
        rewrite "^/thumbnail/([A-Za-z0-9]{12})/(.*)/.*$" /index.php?request=thumbnail&unique=$1&parameters=$2 last;

        # set myns no cache
        set $myns_no_cache 1;
        if ($request_uri ~* "/thumbnail\/.*/") {
                set $myns_no_cache 0;
        }
        if ($request_uri ~* "/serve\/.*\.(jpg|gif|png|swf)/") {
                set $myns_no_cache 0;
        }

        if ($request_uri ~* "/serve\/.*\.(jpg|gif|png|swf)/") {
                set $myns_no_cache 0;
        }

        # upload
        location /upload {
                # proxy to upstream server
                proxy_pass http://static0.mywebsite.com;
                proxy_redirect default;

                # track uploads
                track_uploads uploadproxied 10s;

                # mvc rewrite
                try_files $uri $uri/ /index.php?request=upload&$args;
        }

        # /
        location / {
                # expires
                expires max;

                # disable etag
                if_modified_since off;
                add_header 'Last-Modified' '';

                # mvc rewrite
                try_files $uri $uri/ /index.php?$uri&$args;
        }

        # progress
        location /progress {
                # report uploads tracked in the 'proxied' zone
                report_uploads uploadproxied;
        }

        # php5-fpm
        location ~ \.php$ {
                fastcgi_pass 127.0.0.1:9003;
                fastcgi_param myns_PATH /home/mywebsite/myns;
                fastcgi_index index.php;
                fastcgi_read_timeout 300;
                include fastcgi_params;
                fastcgi_intercept_errors on;
                fastcgi_cache_bypass $myns_no_cache;
                fastcgi_no_cache $myns_no_cache;
                fastcgi_cache mynsCACHE;
                fastcgi_cache_valid any 1h;
        }

        # deny access to .htaccess and .user.ini files
        location ~ /\.[ht|user] {
                deny all;
        }

        # disable access log for better performace use at will
        # access_log /home/mywebsite/myns-projects/mywebsite_com/logs/static_access.log;
        access_log off;

        # logs
        error_log /home/mywebsite/myns-projects/mywebsite_com/logs/static_error.log;
}

After submitting response the jsonp return well but always received equal as size.

jQuery110109778769564112372_1428954161844({ "state" : "uploading", "received" : 2461040, "size" : 2461040 });

Nginx Version:

:~# nginx -V
nginx version: nginx/1.6.2
built by gcc 4.7.2 (Debian 4.7.2-5) 
TLS SNI support enabled
configure arguments: --with-cc-opt='-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2' --with-ld-opt=-Wl,-z,relro --prefix=/usr/share/nginx --conf-path=/etc/nginx/nginx.conf --http-log-path=/var/log/nginx/access.log --error-log-path=/var/log/nginx/error.log --lock-path=/var/lock/nginx.lock --pid-path=/run/nginx.pid --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --with-debug --with-pcre-jit --with-ipv6 --with-http_ssl_module --with-http_stub_status_module --with-http_realip_module --with-http_auth_request_module --with-file-aio --with-http_spdy_module --with-http_addition_module --with-http_dav_module --with-http_flv_module --with-http_geoip_module --with-http_gzip_static_module --with-http_gunzip_module --with-http_image_filter_module --with-http_mp4_module --with-http_perl_module --with-http_random_index_module --with-http_secure_link_module --with-http_sub_module --with-http_xslt_module --with-mail --with-mail_ssl_module --add-module=/usr/src/nginx/source/dotdeb-nginx/debian/modules/headers-more-nginx-module --add-module=/usr/src/nginx/source/dotdeb-nginx/debian/modules/naxsi/naxsi_src --add-module=/usr/src/nginx/source/dotdeb-nginx/debian/modules/nginx-auth-ldap --add-module=/usr/src/nginx/source/dotdeb-nginx/debian/modules/nginx-auth-pam --add-module=/usr/src/nginx/source/dotdeb-nginx/debian/modules/nginx-cache-purge --add-module=/usr/src/nginx/source/dotdeb-nginx/debian/modules/nginx-dav-ext-module --add-module=/usr/src/nginx/source/dotdeb-nginx/debian/modules/nginx-development-kit --add-module=/usr/src/nginx/source/dotdeb-nginx/debian/modules/nginx-echo --add-module=/usr/src/nginx/source/dotdeb-nginx/debian/modules/ngx-fancyindex --add-module=/usr/src/nginx/source/dotdeb-nginx/debian/modules/nginx-push-stream-module --add-module=/usr/src/nginx/source/dotdeb-nginx/debian/modules/nginx-lua --add-module=/usr/src/nginx/source/dotdeb-nginx/debian/modules/nginx-upload-progress --add-module=/usr/src/nginx/source/dotdeb-nginx/debian/modules/nginx-upstream-fair --add-module=/usr/src/nginx/source/dotdeb-nginx/debian/modules/nginx-syslog --add-module=/usr/src/nginx/source/dotdeb-nginx/debian/modules/ngx_http_pinba_module --add-module=/usr/src/nginx/source/dotdeb-nginx/debian/modules/ngx_http_substitutions_filter_module --add-module=/usr/src/nginx/source/dotdeb-nginx/debian/modules/ngx_pagespeed --add-module=/usr/src/nginx/source/dotdeb-nginx/debian/modules/nginx-x-rid-header --add-module=/usr/src/nginx/source/dotdeb-nginx/debian/modules/nginx-rtmp-module --with-ld-opt=-lossp-uuid

3 Answers3

2

I ran into this issue, and have created a pull request to restore the functionality of the nginx-upload-progress module with HTTP/2

https://github.com/masterzen/nginx-upload-progress-module/pull/57

With this fix, it should just work as it did before.

Allan Jude
  • 1,286
  • 9
  • 13
1

I cant comment on previous answer

I have same problem

  location ^~ /upload/progress {
    upload_progress_json_output;
    report_uploads uploadtracker;
  }
  
  location / {
    uwsgi_pass  core;
    uwsgi_param HTTP_X_FORWARDED_PROTO $scheme;
    include     /etc/nginx/uwsgi_params;
    uwsgi_read_timeout 300;
    uwsgi_send_timeout 300;
    track_uploads uploadtracker 300s;
  }

but still received instantly equals size

javascript

    $.ajax({
    type: "GET", //post gives 405
    url: "/upload/progress/",
    beforeSend: function(request) {
        request.setRequestHeader("X-Progress-ID", uuid);
        request.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
    },
    success: function(response) {
        try {
            switch(response.state) {
                case "uploading":
                    percent = parseInt(Math.floor((response.received / response.size)*100)); // always 100

P.S. I found that http2 breaks it, without http2 in listen everything works: https://github.com/masterzen/nginx-upload-progress-module/issues/45

1

track_uploads syntax: track_uploads < zone_name> < timeout>

default: n/a

context: location

This directive enables tracking uploads for the current location. Each POST landing in this location will register the request in the zone_name 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 timeout seconds after they have been finished to be able to serve unseful 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. Repeating the directive in a location will results in segfaults.

So it seems that the track_uploads must be the last directive in the location block. Try switching your track_uploads and try_files directives in the /upload location.

gnur
  • 149
  • 7