Hello,

Please help me set upload progress, since I wasn't able to make it work simple following module instructions. I have latest module version (7.x-2.3) . I see "Upload progress nginx Enabled (upload progress module )" in Status report.

My nginx configuration is:

root@server:~# nginx -V
nginx version: nginx/1.2.5
TLS SNI support enabled
configure arguments: --prefix=/etc/nginx/ --sbin-path=/usr/sbin/nginx --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_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_stub_status_module --with-mail --with-mail_ssl_module --with-file-aio --with-ipv6 --add-module=/usr/src/nginx-upload-progress-module-master

I have upload_progress uploads 1m; string in /etc/nginx/nginx.conf

I have this in my virtual host configuration file:

server {
        listen *:80;
        index index.php index.html;
        server_name site.com;

location ^~ /progress {
  access_log off;
  upload_progress_json_output;
  report_uploads uploads;
}

location ~ (.*)/x-progress-id:(\w*) {
  rewrite ^(.*)/x-progress-id:(\w*)  $1?X-Progress-ID=$2;
}

Now after "root@server:~# service nginx restart" I got:

unknown directive " " in /etc/nginx/sites-enabled/site.com:11

Also, I got
An unrecoverable error occurred. The uploaded file likely exceeded the maximum file size (200 MB) that this server supports. testing 4Mb file upload.

I saw similar issues in issue queue (all closed and resolved(?)) so feel I'm doing something wrong, but not sure what exactly.
So please could someone point me in the right direction.

Thank you!

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

perusio’s picture

You have first a config problem. Also after changing the nginx config there's no need for a restart but rather a reload.

You have a config that is not the correct one for D7. The regex double capture is an overkill.

perusio’s picture

Assigned: Unassigned » perusio
yurg’s picture

Thank you perusio for your help. Indeed, these rules was taken somewhere from internet just after I tried to use "default: module instructions. I just tried to use D7 code from Nginx configuration #2 ("Do a rewrite to support the way that the Nginx module reports the progress.") and got the same

root@server:~# service nginx reload
Reloading nginx configuration: nginx: [emerg] unknown directive "  " in /etc/nginx/sites-enabled/site.com:12
nginx: configuration file /etc/nginx/nginx.conf test failed

where line 12 is:

   rewrite ^ $upload_form_uri?X-Progress-ID=$upload_id;

I did change nginx version to 1.2.1, just in case, so now I have this:

root@server:~# nginx -V
nginx version: nginx/1.2.1
TLS SNI support enabled
configure arguments: --prefix=/etc/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-log-path=/var/log/nginx/access.log --http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --lock-path=/var/lock/nginx.lock --pid-path=/var/run/nginx.pid --with-pcre-jit --with-debug --with-http_addition_module --with-http_dav_module --with-http_flv_module --with-http_geoip_module --with-http_gzip_static_module --with-http_image_filter_module --with-http_mp4_module --with-http_perl_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_stub_status_module --with-http_ssl_module --with-http_sub_module --with-http_xslt_module --with-ipv6 --with-sha1=/usr/include/openssl --with-md5=/usr/include/openssl --with-mail --with-mail_ssl_module --add-module=/build/buildd-nginx_1.2.1-2~bpo60+1-i386-9Rqg9m/nginx-1.2.1/debian/modules/nginx-auth-pam --add-module=/build/buildd-nginx_1.2.1-2~bpo60+1-i386-9Rqg9m/nginx-1.2.1/debian/modules/chunkin-nginx-module --add-module=/build/buildd-nginx_1.2.1-2~bpo60+1-i386-9Rqg9m/nginx-1.2.1/debian/modules/headers-more-nginx-module --add-module=/build/buildd-nginx_1.2.1-2~bpo60+1-i386-9Rqg9m/nginx-1.2.1/debian/modules/nginx-development-kit --add-module=/build/buildd-nginx_1.2.1-2~bpo60+1-i386-9Rqg9m/nginx-1.2.1/debian/modules/nginx-echo --add-module=/build/buildd-nginx_1.2.1-2~bpo60+1-i386-9Rqg9m/nginx-1.2.1/debian/modules/nginx-http-push --add-module=/build/buildd-nginx_1.2.1-2~bpo60+1-i386-9Rqg9m/nginx-1.2.1/debian/modules/nginx-lua --add-module=/build/buildd-nginx_1.2.1-2~bpo60+1-i386-9Rqg9m/nginx-1.2.1/debian/modules/nginx-upload-module --add-module=/build/buildd-nginx_1.2.1-2~bpo60+1-i386-9Rqg9m/nginx-1.2.1/debian/modules/nginx-upload-progress --add-module=/build/buildd-nginx_1.2.1-2~bpo60+1-i386-9Rqg9m/nginx-1.2.1/debian/modules/nginx-upstream-fair --add-module=/build/buildd-nginx_1.2.1-2~bpo60+1-i386-9Rqg9m/nginx-1.2.1/debian/modules/nginx-dav-ext-module

and upload_progress uploads 1m; in http block of nginx.conf .

I doubt if <upload_form_uri> should be real uri of page where upload form is located. Also, "Use the 3rd party Upload Progress Nginx module." link on module main page is dead (https://github.com/masterzen/nginx-upload%20progress-module points to non-existent page.). I was able to use build instructions link ( http://wiki.nginx.org/HttpUploadProgressModule#Installation ) but still no luck.

Looks like I missed something really obvious. Please point me in the right direction. Thank you!

perusio’s picture

I'm wondering if this comes from a bad PCRE library version that makes the regexes go mad. Just to be sure. Comment out all
Upload Progress module stuff and do the following:

location /test {
    location ~* ^/test/.*\.txt$ {}
}

Create a test directory and do touch a.txt. Now curl -I site.com/test/a.txt must check the empty text file.

yurg’s picture

Thank you for your help. Now test code gives me exactly same message

root@server:~# service nginx reload
Reloading nginx configuration: nginx: [emerg] unknown directive "   " in /etc/nginx/sites-enabled/site.com:33

where line 33 is here:

location /test {
 #Line 33 ---> #    location ~* ^/test/.*\.txt$ {}
}  

Something with my nginx I guess? But I have other rewrite rules which works (or at least which are silent afater nginx reload):

  location ~ ^.*/files/imagecache/.+$ {
 ...
  location ~* /(?:external|system|files/imagecache|files/styles)/ {
...
perusio’s picture

Ok. It seems there's a problem with your PCRE library. What does ldd /usr/sbin/nginx give for you?

Here's mine:

ldd /usr/sbin/nginx
        linux-vdso.so.1 =>  (0x00007fff7eb9b000)
        libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fd455731000)
        libcrypt.so.1 => /lib/x86_64-linux-gnu/libcrypt.so.1 (0x00007fd4554fa000)
        libluajit-5.1.so.2 => /usr/lib/x86_64-linux-gnu/libluajit-5.1.so.2 (0x00007fd45528b000)
        libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fd455009000)
        libpcre.so.3 => /lib/x86_64-linux-gnu/libpcre.so.3 (0x00007fd454dcc000)
        libssl.so.1.0.0 => /usr/lib/x86_64-linux-gnu/libssl.so.1.0.0 (0x00007fd454b6d000)
        libcrypto.so.1.0.0 => /usr/lib/x86_64-linux-gnu/libcrypto.so.1.0.0 (0x00007fd454789000)
        libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fd454585000)
        libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007fd45436d000)
        libgd.so.2 => /usr/lib/x86_64-linux-gnu/libgd.so.2 (0x00007fd454125000)
        libGeoIP.so.1 => /usr/lib/libGeoIP.so.1 (0x00007fd453eef000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fd453b64000)
        /lib64/ld-linux-x86-64.so.2 (0x00007fd455963000)
        libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fd45394e000)
        libXpm.so.4 => /usr/lib/x86_64-linux-gnu/libXpm.so.4 (0x00007fd45373c000)
        libX11.so.6 => /usr/lib/x86_64-linux-gnu/libX11.so.6 (0x00007fd453400000)
        libjpeg.so.8 => /usr/lib/x86_64-linux-gnu/libjpeg.so.8 (0x00007fd4531c6000)
        libfontconfig.so.1 => /usr/lib/x86_64-linux-gnu/libfontconfig.so.1 (0x00007fd452f8e000)
        libfreetype.so.6 => /usr/lib/x86_64-linux-gnu/libfreetype.so.6 (0x00007fd452cef000)
        libpng12.so.0 => /lib/x86_64-linux-gnu/libpng12.so.0 (0x00007fd452ac8000)
        libxcb.so.1 => /usr/lib/x86_64-linux-gnu/libxcb.so.1 (0x00007fd4528a7000)
        libexpat.so.1 => /lib/x86_64-linux-gnu/libexpat.so.1 (0x00007fd45267d000)
        libXau.so.6 => /usr/lib/x86_64-linux-gnu/libXau.so.6 (0x00007fd452479000)
        libXdmcp.so.6 => /usr/lib/x86_64-linux-gnu/libXdmcp.so.6 (0x00007fd452274000)

Can you get a debug log output? http://nginx.org/en/docs/debugging_log.html

yurg’s picture

Here's it ( your's is 64bit ):

root@server:~# ldd /usr/sbin/nginx
	linux-gate.so.1 =>  (0xf57fe000)
	libpthread.so.0 => /lib/i686/cmov/libpthread.so.0 (0xb77bc000)
	libcrypt.so.1 => /lib/i686/cmov/libcrypt.so.1 (0xb778a000)
	libpam.so.0 => /lib/libpam.so.0 (0xb777e000)
	libm.so.6 => /lib/i686/cmov/libm.so.6 (0xb7757000)
	liblua5.1.so.0 => /usr/lib/liblua5.1.so.0 (0xb7731000)
	libexpat.so.1 => /usr/lib/libexpat.so.1 (0xb770b000)
-->>	libpcre.so.3 => /lib/libpcre.so.3 (0xb76d8000)
	libssl.so.0.9.8 => /usr/lib/i686/cmov/libssl.so.0.9.8 (0xb768e000)
	libcrypto.so.0.9.8 => /usr/lib/i686/cmov/libcrypto.so.0.9.8 (0xb7535000)
	libdl.so.2 => /lib/i686/cmov/libdl.so.2 (0xb7531000)
	libz.so.1 => /usr/lib/libz.so.1 (0xb751d000)
	libxml2.so.2 => /usr/lib/libxml2.so.2 (0xb73f3000)
	libxslt.so.1 => /usr/lib/libxslt.so.1 (0xb73bb000)
	libexslt.so.0 => /usr/lib/libexslt.so.0 (0xb73a9000)
	libgd.so.2 => /usr/lib/libgd.so.2 (0xb7366000)
	libGeoIP.so.1 => /usr/lib/libGeoIP.so.1 (0xb732e000)
	libperl.so.5.10 => /usr/lib/libperl.so.5.10 (0xb71df000)
	libc.so.6 => /lib/i686/cmov/libc.so.6 (0xb7098000)
	/lib/ld-linux.so.2 (0xb77e0000)
	libgcrypt.so.11 => /usr/lib/libgcrypt.so.11 (0xb7024000)
	libXpm.so.4 => /usr/lib/libXpm.so.4 (0xb7013000)
	libX11.so.6 => /usr/lib/libX11.so.6 (0xb6ef6000)
	libjpeg.so.62 => /usr/lib/libjpeg.so.62 (0xb6ed6000)
	libfontconfig.so.1 => /usr/lib/libfontconfig.so.1 (0xb6ea7000)
	libfreetype.so.6 => /usr/lib/libfreetype.so.6 (0xb6e2f000)
	libpng12.so.0 => /lib/libpng12.so.0 (0xb6e0a000)
	libgpg-error.so.0 => /usr/lib/libgpg-error.so.0 (0xb6e06000)
	libxcb.so.1 => /usr/lib/libxcb.so.1 (0xb6ded000)
	libXau.so.6 => /usr/lib/libXau.so.6 (0xb6dea000)
	libXdmcp.so.6 => /usr/lib/libXdmcp.so.6 (0xb6de5000)

Going to configure with debugging log.

yurg’s picture

Nothing unusual in server logs after debug.

cat /var/log/nginx/error.log
2012/12/14 11:50:09 [emerg] 13005#0: unknown directive "   " in /etc/nginx/sites-enabled/site.com:33
2012/12/14 11:50:09 [emerg] 13006#0: unknown directive "   " in /etc/nginx/sites-enabled/site.com:33
2012/12/14 11:51:23 [emerg] 13012#0: unknown directive "   " in /etc/nginx/sites-enabled/site.com:33
2012/12/14 11:51:23 [emerg] 13013#0: unknown directive "   " in /etc/nginx/sites-enabled/site.com:33

But may be this:

cat /srv/www/site.com/logs/nginx.error.log 
2012/12/14 11:53:06 [error] 3606#0: *163 no user/password was provided for basic authentication, client: , server: site.com, request: "GET /progress HTTP/1.0", host: "site.com"
2012/12/14 11:53:07 [error] 3606#0: *165 no user/password was provided for basic authentication, client: , server: site.com, request: "GET /progress HTTP/1.0", host: "site.com"
2012/12/14 11:53:09 [error] 3606#0: *167 no user/password was provided for basic authentication, client: , server: site.com, request: "GET /progress HTTP/1.0", host: "site.com"
2012/12/14 11:53:11 [error] 3606#0: *169 no user/password was provided for basic authentication, client: , server: site.com, request: "GET /progress HTTP/1.0", host: "site.com"

auth_basic directive was commented out while upload progress testing though.

perusio’s picture

I don't think it's a config problem. I'm inclined to think about a problem with your nginx binary, either stemming from a bad PCRE library or a build process gone wrong somewhere.

Try other version and or package and see how it goes.

yurg’s picture

I made some tests trying ti isolate this issue: same nginx 1.2.4 was configured locally and remotely using same methods and same technique. Now upload progress works locally but still doesn't work remotely, with nginx reload fail message:

Restarting nginx: nginx: [emerg] unknown directive "  " in /etc/nginx/sites-enabled/site.com:12
location ~ (?<upload_form_uri>.*)/x-progress-id:(?<upload_id>\d*) {
#Line 12 below #
   rewrite ^ $upload_form_uri?X-Progress-ID=$upload_id; 
# Line 12 above #
}

Configuration comparisons between local and remote servers are attached (both nginx -V and ldd /usr/sbin/nginx ).
Looks like dead end from my side so any suggestions would be highly appreciated. Thank you!

yurg’s picture

Status: Active » Fixed

Issue was resolved with help from StackOverflow: http://stackoverflow.com/questions/14007391/unknown-directive-in-etc-ngi... Indeed, it was caused by PCRE version on server. So, simplified rewrite rule was used instead of "default":

## 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 ~ (.*)/x-progress-id:([0-9]+) {
    set $upload_form_uri $1;
    set $progress_id $2;
    rewrite .* $upload_form_uri?X-Progress-ID=$progress_id;
}
perusio’s picture

Indeed, somehow the PCRE library is broken or is too old. The inclusion of the variables is completely unnecessary. Try:

location ~ (.*)/x-progress-id:([0-9]+) {
    rewrite ^ $1?X-Progress-ID=$2;
}
yurg’s picture

@perusio

Thank you for suggestion, tried your code, doesn't work unfortunately with same "unknown directive".
Looks like my case is rare indeed, so if anyone will "luckily" face it in a future, code from http://drupal.org/node/1862462#comment-6872466 provides working fix for it.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

ispboy’s picture

for PCRE prior to 7.0

change (?< to (?P<

## Drupal 7 config.
location ~ (?<upload_form_uri>.*)/x-progress-id:(?<upload_id>\d*) {
   rewrite ^ $upload_form_uri?X-Progress-ID=$upload_id;
}