Welcome! Log In Create A New Profile

Advanced

Настройка Upload Module + Upload Progress Module

Posted by coconut 
Настройка Upload Module + Upload Progress Module
February 20, 2012 08:15AM
Здравствуйте!

Пытаюсь настроить связку Upload Module + Upload Progress Module. Конфиг такой:

server {
listen 80;
server_name srv.rapid.loc;

# Define root
set $fs_webroot "/home/coconut/public_html/project/srv";
root $fs_webroot;
index index.php;

# robots.txt
location = /robots.txt {
alias $fs_webroot/deny.robots.txt;
}

# Domain root
location / {
try_files $uri $uri/ /index.php?$query_string;
if ($query_string ~ "r=upload&X-Progress-ID=") {
upload_pass /;
upload_limit_rate 1024;
upload_store /tmp/nginxupload;
upload_cleanup 400 404 499 500-505;
}
}

location ~ index.php {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $fs_webroot/$fastcgi_script_name;
include fastcgi_params;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param PATH_INFO $fastcgi_script_name;

add_header Pragma no-cache;
add_header Cache-Control no-cache,must-revalidate;
add_header Access-Control-Allow-Origin *;

track_uploads proxied 35s;
}

location ^~ /progress {
expires off;
add_header Pragma no-cache;
add_header Cache-Control no-cache,must-revalidate;
add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Headers "Content-Type, X-Requested-With, X-File-Name";

report_uploads proxied;
}
}

Форма шлется по такому урлу:
http://srv.rapid.loc/?r=upload&X-Progress-ID=5d5f51c3b27c8af0c2eb512d59a3c821

Файл загружается, скорость режется, но прогресс не возвращается. Т.е. при запросе прогресса:
http://srv.rapid.loc/progress/?X-Progress-ID=5d5f51c3b27c8af0c2eb512d59a3c821
все время возвращается:
new Object({ 'state' : 'starting' })

/etc/nginx/nginx.conf:
user www-data;
worker_processes 4;
pid /var/run/nginx.pid;

events {
worker_connections 768;
# multi_accept on;
}

http {
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
client_max_body_size 1g;
# server_tokens off;
server_names_hash_max_size 2048;
server_names_hash_bucket_size 128;
upload_progress proxied 32m;

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

access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;

gzip on;
gzip_disable "msie6";

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


В чем может быть проблема?
Re: Настройка Upload Module + Upload Progress Module
May 03, 2012 09:09AM
присоединяюсь к вопросу, такая же проблема =(
nginx -V:
nginx: nginx version: nginx/1.0.5
nginx: built by gcc 4.1.2
nginx: configure arguments: --with-pcre --with-http_flv_module --with-http_dav_module --with-http_stub_status_module --with-http_image_filter_module --with-http_realip_module --with-http_gzip_static_module --with-http_perl_module --add-module=../nginx_upload_module-2.2.0 --add-module=../masterzen-nginx-upload-progress-module-8b55a34

nginx.conf:
user httpd nobody;
pid /var/run/nginx.pid;
worker_processes 2;
worker_rlimit_nofile 10240;

events {
worker_connections 1024;
}

http {
include /usr/local/nginx/conf/mime.types;
default_type text/html;
charset utf-8;

index index.html;
merge_slashes on;

client_max_body_size 2000m;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 30;
server_tokens off;


log_format main '$remote_addr - $remote_user [$time_local] "$request" $status $body_bytes_sent '
'"$http_referer" "$http_user_agent" "$http_x_forwarded_for" '
'"$http_cookie" "$upstream_http_set_cookie" "$upstream_http_x_auth_ticket" "[$request_time]"';
access_log /var/log/nginx/access.log main;
error_log /var/log/nginx/error.log;


gzip on;
gzip_types text/plain application/xml application/x-javascript application/javascript text/css;
gzip_http_version 1.1;
gzip_comp_level 3;
gzip_proxied any;
gzip_buffers 32 8k;


proxy_cache_path /var/cache/nginx/cache levels=1:2 keys_zone=C1:15m inactive=6h max_size=1024m;
proxy_cache_use_stale error timeout invalid_header http_500 http_502 http_503 http_504;
proxy_temp_path /var/cache/nginx/proxy_temp;
proxy_cache_bypass $cookie_ticket;
proxy_no_cache $cookie_ticket;


open_file_cache max=2048 inactive=60s;
open_file_cache_valid 90s;
open_file_cache_min_uses 2;
open_file_cache_errors on;


perl_set $unescaped_uri 'sub {
(my $uri = $_[0]->uri) =~ s|%20| |g;
return $uri;
}';
perl_set $escaped_uri 'sub {
(my $uri = $_[0]->uri) =~ s|\s|%20|g;
return $uri;
}';


include /usr/local/nginx/conf/webpool/*.conf;
}


webpool/site.conf:
upload_progress proxied 100m;
server {
server_name site.ru;
listen 7070;

charset utf-8;

access_log logs/site.access.log;
error_log logs/site.error.log debug;
log_subrequest on;
log_not_found on;

error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;


location @backend {
proxy_pass http://localhost:12666;
proxy_set_header X-Real-IP $remote_addr;

track_uploads proxied 300s;
}

location = /test_features/file_upload/upload.html {
upload_pass @backend;
upload_store /usr/local/scompany/db/data/site/tmp 1;
upload_store_access user:rw group:rw;
upload_set_form_field $upload_field_name.name "$upload_file_name";
upload_set_form_field $upload_field_name.content_type "$upload_content_type";
upload_set_form_field $upload_field_name.path "$upload_tmp_path";
upload_aggregate_form_field "$upload_field_name.md5" "$upload_file_md5";
upload_aggregate_form_field "$upload_field_name.size" "$upload_file_size";
}

location = /test_features/file_upload/progress.html {
report_uploads proxied;
}

location / {
root /usr/local/company/web/htdocs/site/;
try_files $uri $uri/index.html @backend;
}

location /images {
alias /usr/local/company/web/htdocs/site/images;
}

location /data/ {
alias /usr/local/stack/db/data/site/;
}

location ~ ^/data/(.*)\.(.+)x(.+)x(.+)\.(jpg)$ {
set $height $3;
set $width $2;
set $ipath $1;
rewrite ^ /___resize/data/$ipath;
}

location /___resize/data/ {
alias /usr/local/company/db/data/site;
image_filter resize $width $height;
}
}


logs:
==> /usr/local/nginx/logs/site.error.log <==
2012/05/03 16:59:46 [info] 19405#0: *1 started uploading file "chakra-2012.04-Archimedes-x86_64.iso" to "/usr/local/company/db/data/site/tmp/9/0031738829" (field "datafile1", content type "application/x-cd-image"), client: 217.73.198.239, server: potato.company.net, request: "POST /site/test_features/file_upload/upload.html?X-Progress-ID=71fd04bd3bad32facdec38cf3ff96d3d HTTP/1.1", host: "potato.company.net:7070", referrer: "http://potato.company.net:7070/site/test_features/file_upload/index.html"

==> /usr/local/nginx/logs/site.access.log <==
217.73.198.239 - - [03/May/2012:16:59:47 +0400] "GET /site/test_features/file_upload/progress.html?X-Progress-ID=71fd04bd3bad32facdec38cf3ff96d3d HTTP/1.1" 200 38 "http://potato.company.net:7070/site/test_features/file_upload/index.html" "Mozilla/5.0 (X11; Linux i686) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.168 Safari/535.19"
217.73.198.239 - - [03/May/2012:16:59:48 +0400] "GET /favicon.ico HTTP/1.1" 304 0 "-" "Mozilla/5.0 (X11; Linux i686) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.168 Safari/535.19"
217.73.198.239 - - [03/May/2012:16:59:49 +0400] "GET /site/test_features/file_upload/progress.html?X-Progress-ID=71fd04bd3bad32facdec38cf3ff96d3d HTTP/1.1" 200 38 "http://potato.company.net:7070/site/test_features/file_upload/index.html" "Mozilla/5.0 (X11; Linux i686) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.168 Safari/535.19"
217.73.198.239 - - [03/May/2012:16:59:49 +0400] "GET /favicon.ico HTTP/1.1" 304 0 "-" "Mozilla/5.0 (X11; Linux i686) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.168 Safari/535.19"
217.73.198.239 - - [03/May/2012:16:59:49 +0400] "GET /site/test_features/file_upload/progress.html?X-Progress-ID=71fd04bd3bad32facdec38cf3ff96d3d HTTP/1.1" 200 38 "http://potato.company.net:7070/site/test_features/file_upload/index.html" "Mozilla/5.0 (X11; Linux i686) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.168 Safari/535.19"
217.73.198.239 - - [03/May/2012:16:59:50 +0400] "GET /favicon.ico HTTP/1.1" 304 0 "-" "Mozilla/5.0 (X11; Linux i686) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.168 Safari/535.19"
217.73.198.239 - - [03/May/2012:16:59:50 +0400] "GET /site/test_features/file_upload/progress.html?X-Progress-ID=71fd04bd3bad32facdec38cf3ff96d3d HTTP/1.1" 200 38 "http://potato.company.net:7070/site/test_features/file_upload/index.html" "Mozilla/5.0 (X11; Linux i686) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.168 Safari/535.19"
217.73.198.239 - - [03/May/2012:16:59:51 +0400] "GET /favicon.ico HTTP/1.1" 304 0 "-" "Mozilla/5.0 (X11; Linux i686) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.168 Safari/535.19"


и после того, как прервал загрузку файла:
==> /usr/local/nginx/logs/site.access.log <==
217.73.198.239 - - [03/May/2012:17:00:03 +0400] "POST /site/test_features/file_upload/upload.html?X-Progress-ID=71fd04bd3bad32facdec38cf3ff96d3d HTTP/1.1" 400 0 "http://potato.company.net:7070/site/test_features/file_upload/index.html" "Mozilla/5.0 (X11; Linux i686) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.168 Safari/535.19"

==> /usr/local/nginx/logs/site.error.log <==
2012/05/03 17:00:03 [info] 19405#0: *1 client closed prematurely connection, client: 217.73.198.239, server: potato.company.net, request: "POST /site/test_features/file_upload/upload.html?X-Progress-ID=71fd04bd3bad32facdec38cf3ff96d3d HTTP/1.1", host: "potato.company.net:7070", referrer: "http://potato.company.net:7070/site/test_features/file_upload/index.html"
2012/05/03 17:00:03 [alert] 19405#0: *1 aborted uploading file "chakra-2012.04-Archimedes-x86_64.iso" to "/usr/local/company/db/data/site/tmp/9/0031738829", dest file removed, client: 217.73.198.239, server: potato.company.net, request: "POST /site/test_features/file_upload/upload.html?X-Progress-ID=71fd04bd3bad32facdec38cf3ff96d3d HTTP/1.1", host: "potato.company.net:7070", referrer: "http://potato.company.net:7070/site/test_features/file_upload/index.html"



Проблема такая же:
до того, как файл загрузится прогресс всегда отображает
new Object({ 'state' : 'starting' })

а после - отображает:
new Object({ 'state' : 'done' })

отображения
new Object({ 'state' : 'uploading', 'received' : <size_received>, 'size' : <total_size>})
никак не удаётся добиться =((((
Re: Настройка Upload Module + Upload Progress Module
May 03, 2012 09:23AM
установка свежей версии nginx так же ничего не дала =(
nginx version: nginx/1.2.0
built by gcc 4.1.2
configure arguments: --with-pcre --with-http_flv_module --with-http_dav_module --with-http_stub_status_module --with-http_image_filter_module --with-http_realip_module --with-http_gzip_static_module --with-http_perl_module --add-module=../nginx_upload_module-2.2.0/ --add-module=../masterzen-nginx-upload-progress-module-82b35fc
Re: Настройка Upload Module + Upload Progress Module
May 05, 2012 06:26AM
Я нашёл причину поведения. Не знаю, насколько это очевидно и правильно, (и насколько это соответствует документации для модуля), но
у меня всё заработало после того, как я поместил директиву track_uploads не в location @backend, туда, где вызывается директива upload_pass @backend.

Не знаю, ошибка ли это, но с таким конфигом оно хотя бы работает =)
Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 66
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready