利用Nginx的Upload模块实现无限制大文件上传

server
{
listen 80;
server_name 1.server.xxx;
index index.html index.htm index.php;
root /web/vhosts/1.server.xxx/www;

location = /upload.php {
client_body_timeout 9999s; //最大允许的上传时间
client_max_body_size 300m; //最大上传大小
upload_pass @upload;
upload_store /web/vhosts/1.server.xxx/protected/runtime/files-tmp 1;
upload_store_access user:r;

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_cleanup 400-599;

upload_pass_args on;
}

location @upload {
fastcgi_next_upstream error timeout invalid_header http_500 http_503;
fastcgi_pass backend;
fastcgi_index index.php;
include fcgi.conf;
}

location ~ .*\.php?$
{
fastcgi_next_upstream error timeout invalid_header http_500 http_503;
fastcgi_pass backend;
fastcgi_index index.php;
include fcgi.conf;
}

location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}

location ~ .*\.(js|css)?$
{
expires 12h;
}
}

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据