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

Received and size are the same #44

Closed rbairwell closed 8 years ago

rbairwell commented 8 years ago

This is a continuation of the closed issue #36 where the received and size are the same even though the upload is continuing (tested using Firefox on a 3.4Gb file through Charles Proxy throttled to 56kbps). In that thread, others are reporting they are continuing to have this issue.

Built on nginx mainline 1.9.15 (also tried 1.1.10) on Debian jessie (under vagrant) using module v0.9.1.tar.gz.

Build steps used (based off https://serversforhackers.com/compiling-third-party-modules-into-nginx )

Ensure /etc/apt/sources.list.d/nginx.list has an uncommented deb-src :

deb http://nginx.org/packages/mainline/debian/ jessie nginx
deb-src http://nginx.org/packages/mainline/debian/ jessie nginx

sudo apt-get update
sudo apt-get remove nginx-common nginx nginx-extras

# Download module
sudo mkdir /opt/nginxuploadprogressmodule
cd /opt/nginxuploadprogressmodule
sudo wget https://github.com/masterzen/nginx-upload-progress-module/archive/v0.9.1.tar.gz
sudo tar xvf v0.9.1.tar.gz

# Install package creation tools
sudo apt-get install -y dpkg-dev

sudo mkdir /opt/rebuildnginx
cd /opt/rebuildnginx

# Get Nginx source files
sudo apt-get source nginx

# Install the build dependencies
sudo apt-get build-dep nginx

# Edit (sudo) /opt/rebuildnginx/nginx-1.9.15/debian/rules to add at the bottom of the configure flags (ensure \ is included on previous line)
# --add-module=/opt/nginxuploadprogressmodule/nginx-upload-progress-module-0.9.1

# now build
cd /opt/rebuildnginx/nginx-1.9.15
sudo dpkg-buildpackage -b

# once completed, install it
cd /opt/rebuildnginx/
sudo dpkg --install nginx_1.9.15-1~jessie_amd64.deb

# checking the version should show the module installed
sudo nginx -V
nginx version: nginx/1.9.15
built by gcc 4.9.2 (Debian 4.9.2-10)
built with OpenSSL 1.0.1k 8 Jan 2015
TLS SNI support enabled
configure arguments: --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_stub_status_module --with-http_auth_request_module --with-http_xslt_module=dynamic --with-http_image_filter_module=dynamic --with-http_geoip_module=dynamic --with-http_perl_module=dynamic --add-dynamic-module=debian/extra/njs-1c50334fbea6/nginx --with-threads --with-stream --with-stream_ssl_module --with-http_slice_module --with-mail --with-mail_ssl_module --with-file-aio --with-ipv6 --with-http_v2_module --with-cc-opt='-g -O2 -fstack-protector-strong -Wformat -Werror=format-security' --with-ld-opt=-Wl,-z,relro --add-module=/opt/nginxuploadprogressmodule/nginx-upload-progress-module-0.9.1

sudo systemctl unmask nginx.service

cat /etc/nginx/nginx.conf

user  vagrant;
worker_processes  1;

error_log  /var/log/nginx/error.log debug;
pid        /var/run/nginx.pid;

events {
    worker_connections  1024;
}

http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    sendfile off;
    #tcp_nopush     on;
    client_max_body_size 4M;
    keepalive_timeout  65;

    #gzip  on;

    include /etc/nginx/conf.d/*.conf;
}

Relevant /etc/nginx/nginx/*.conf entries

upload_progress uploads 1M;
client_body_buffer_size 32k;

server {
    listen 85;
    server_name ""
                192.168.7.7;
    root   /var/www/.../public/;
    index  index.php index.html index.htm;
    access_log /var/www/.../log/access.log;
    error_log /var/www/.../log/error.log debug;

    client_max_body_size 4096M;
    location ^~ /.../progress {
        report_uploads uploads;
    }
    location / {
        include php.conf;
        try_files $uri $uri/ /index.php$is_args$args;
    }
    sendfile off;
    location = /.../upload/file {
        try_files $uri $uri/ /index.php$is_args$args;
        include php.conf;
        track_uploads uploads 60s;
    }

}

Running with debug enabled shows in system log:

2016/05/13 13:08:58 [notice] 1051#1051: using the "epoll" event method
2016/05/13 13:08:58 [notice] 1051#1051: nginx/1.9.15
2016/05/13 13:08:58 [notice] 1051#1051: built by gcc 4.9.2 (Debian 4.9.2-10)
2016/05/13 13:08:58 [notice] 1051#1051: OS: Linux 3.2.0-4-amd64
2016/05/13 13:08:58 [notice] 1051#1051: getrlimit(RLIMIT_NOFILE): 1024:4096
2016/05/13 13:08:58 [notice] 1052#1052: start worker processes
2016/05/13 13:08:58 [notice] 1052#1052: start worker process 1053

and in the site specific log:

2016/05/13 13:09:15 [warn] 1053#1053: *1 a client request body is buffered to a temporary file /var/cache/nginx/client_temp/0000000001, client: 192.168.7.1, server: , request: "POST /.../upload/file?X-Progress-ID=123 HTTP/1.1", host: "192.168.7.7:85", referrer: "http://....php"

This is my first time trying to add a module to nginx (I did try just using debian's nginx-extras package first, but had the same results) so I might be missing something...

rbairwell commented 8 years ago

Sorry, looks like this may be a configuration issue at my end as I can get it to work with:

    location = /upload.php {
        include php.conf;
        track_uploads proxied 30s;
    }
    location / {
        include php.conf;
        try_files $uri $uri/ /index.php$is_args$args;
    }

on Debian nginx-extras and built from source.