2011-02-17 4 views
2

씬 인스턴스의 리버스 프록시로 Nginx를 사용하고 있습니다.씬 + Nginx + 업로드 모듈 + 업로드 진행 모듈

내 목표는 큰 파일을 업로드하고 그 파일을 사용하여 Rails (3) 앱을 설정하는 것입니다.

Nginx 업로드 및 업로드 진행 모듈을 발견했습니다.

나는 대부분 this 게시물을 읽고 있었지만, 특히 승객의 생각을 썼습니다.

가능하면

, 나는 두 가지 답을 찾고 있어요 : 대신 승객의 얇은)

2)이 재 작성 수있는 방법의 특정 정보 (이 스택을 구현하는

1) 정보 예 :

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; 
     } 

나는 승객 전용이 무엇인지 알지 못한다. 전형적인 4 노동자/3 씬 인스턴스 conf에 쓰는 방법을 모른다.

감사합니다.

답변

3

먼저 업로드 모듈을 사용하여 nginx를 설치해야합니다. 사이트에 대한 nginx 구성 :

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; 
    } 
} 
+0

감사합니다. – maukoquiroga

관련 문제