|
1 | 1 | nginx-upload-module
|
2 | 2 | ===================
|
| 3 | + |
| 4 | +This module is based on Nginx upload module (v 2.2.0) http://www.grid.net.ru/nginx/upload.en.html. |
| 5 | +Since it seems the author has not maintained that module. I changed some codes that can be installed with latest nginx. |
| 6 | + |
| 7 | +- install |
| 8 | +./configure --add-module={module_dir} && make && make install |
| 9 | + |
| 10 | +- conf |
| 11 | +``` |
| 12 | +server { |
| 13 | + listen 80; |
| 14 | + client_max_body_size 100m; |
| 15 | +
|
| 16 | + location / { |
| 17 | + root html/upload; |
| 18 | + } |
| 19 | +
|
| 20 | + # Upload form should be submitted to this location |
| 21 | + location /upload { |
| 22 | + # Pass altered request body to this location |
| 23 | + upload_pass /example.php; |
| 24 | +
|
| 25 | + # Store files to this directory |
| 26 | + # The directory is hashed, subdirectories 0 1 2 3 4 5 6 7 8 9 should exist |
| 27 | + upload_store /tmp/upload 1; |
| 28 | +
|
| 29 | + # Allow uploaded files to be read only by user |
| 30 | + upload_store_access user:r; |
| 31 | +
|
| 32 | + # Set specified fields in request body |
| 33 | + upload_set_form_field "${upload_field_name}_name" $upload_file_name; |
| 34 | + upload_set_form_field "${upload_field_name}_content_type" $upload_content_type; |
| 35 | + upload_set_form_field "${upload_field_name}_path" $upload_tmp_path; |
| 36 | +
|
| 37 | + # Inform backend about hash and size of a file |
| 38 | + upload_aggregate_form_field "${upload_field_name}_md5" $upload_file_md5; |
| 39 | + upload_aggregate_form_field "${upload_field_name}_size" $upload_file_size; |
| 40 | +
|
| 41 | + upload_pass_form_field "^submit$|^description$"; |
| 42 | + } |
| 43 | +
|
| 44 | + location ~ \.php$ { |
| 45 | + root html/upload; |
| 46 | + fastcgi_pass 127.0.0.1:9000; |
| 47 | + fastcgi_index index.php; |
| 48 | + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; |
| 49 | + include fastcgi_params; |
| 50 | + } |
| 51 | +} |
| 52 | +``` |
0 commit comments