首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Thin + Nginx + Upload模块+ Upload进度模块

Thin + Nginx + Upload模块+ Upload进度模块
EN

Stack Overflow用户
提问于 2011-02-17 23:06:46
回答 1查看 1.7K关注 0票数 2

我使用Nginx作为瘦实例的反向代理。

我的目标是设置一个Rails (3)应用程序来上传大文件并对它们做一些事情。

为此,我遇到了Nginx Upload和Upload Progress模块。

我大部分时间都在读this的帖子,但那是专门写在Passenger中的思考。

如果可能,我在寻找两个可能的答案:

1)提供实现此堆栈的示例(使用瘦而不是Passenger)

2)如何重写的具体信息:

代码语言:javascript
复制
   location ^~ /progress {
         # report uploads tracked in the 'proxied' zone
         upload_progress_json_output;
         report_uploads proxied;
       }

       location @fast_upload_endpoint {
         passenger_enabled on;
         rails_env development;
       }

       location / {
         rails_env development;
         passenger_enabled on;
       }

我不知道什么是Passenger exclusive,也不知道如何为典型的4个worker/3 thin instance conf编写它。

谢谢。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2011-06-22 15:01:26

首先,您应该使用upload模块安装nginx。site的nginx配置:

代码语言:javascript
复制
upstream uploader_cluster {
  server unix:/tmp/thin.uploader.0.sock;
  server unix:/tmp/thin.uploader.1.sock;
  server unix:/tmp/thin.uploader.2.sock;
  server unix:/tmp/thin.uploader.3.sock;
  server unix:/tmp/thin.uploader.4.sock;
}

server {
     listen 80;
     server_name ***.com;

     charset off;
     client_max_body_size 1000m;

     access_log /var/www/uploader/log/access.log;
     error_log /var/www/uploader/log/error.log;

     root /var/www/uploader/public;
     index index.html;

     location / {
         proxy_redirect     off;
         proxy_set_header   Host             $host;
         proxy_set_header   X-Real-IP        $remote_addr;
         proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;

         if (-f $request_filename/index.html) {
             rewrite (.*) $1/index.html break;
         }

         if (-f $request_filename.html) {
             rewrite (.*) $1.html break;
         }

         if (!-f $request_filename) {
             proxy_pass http://uploader_cluster;
             break;
         }
     }

     location ~*uploads$ {
        if ($request_method = GET) {
          proxy_pass http://uploader_cluster;
          break;
        }

        # pass request body to here
        upload_pass @upload_photos;

        # Store files to this directory
        # The directory is hashed, subdirectories 0 1 2 3 4 5 6 7 8 9 should exist
        # i.e. make sure to create /vol/uploads/0 /vol/uploads/1 etc.
        upload_store /vol/uploads 1;

        # set permissions on the uploaded files
        upload_store_access user:rw group:rw all:r;

        # Set specified fields in request body
        # this puts the original filename, new path+filename and content type in the requests params
        upload_set_form_field upload[file_name] "$upload_file_name";
        upload_set_form_field upload[file_content_type] "$upload_content_type";
        upload_set_form_field upload[file_path] "$upload_tmp_path";
        upload_aggregate_form_field upload[file_size] "$upload_file_size";

        upload_pass_form_field "^fb_sig_user$|^aid$|^batch_id$|^album_name$|^album_visible$|^caption$|^tags$|^complete$";

        upload_cleanup 400 404 499 500-505;
     }

     location @upload_photos {
        proxy_pass http://uploader_cluster;
     }
}
票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/5030669

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档