Skip to content

Commit 5f5fd2c

Browse files
committed
nginx upload module
1 parent 4d16a4a commit 5f5fd2c

File tree

4 files changed

+4043
-0
lines changed

4 files changed

+4043
-0
lines changed

README.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,52 @@
11
nginx-upload-module
22
===================
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+
```

config

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
USE_MD5=YES
2+
USE_SHA1=YES
3+
ngx_addon_name=ngx_http_upload_module
4+
HTTP_MODULES="$HTTP_MODULES ngx_http_upload_module"
5+
NGX_ADDON_SRCS="$NGX_ADDON_SRCS $ngx_addon_dir/ngx_http_upload_module.c"

0 commit comments

Comments
 (0)