forked from pirsipy/cdn
-
Notifications
You must be signed in to change notification settings - Fork 0
/
nginx.conf
80 lines (62 loc) · 1.72 KB
/
nginx.conf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
upstream upload {
server 127.0.0.1:8001;
}
upload_progress proxied 1m;
server {
listen 8080;
server_name localhost;
set $BASE_PATH /home/webmaster/app;
set $files $BASE_PATH/files;
set $cache $BASE_PATH/cache;
set $image_handler $BASE_PATH/image_handler.lua;
set $magick_path $BASE_PATH/magick.lua;
client_max_body_size 512m;
client_body_buffer_size 1024k;
location ~ ^/(?<path>.*\.(?<ext>.*))$ {
root $get_root;
set $limit_rate 2m;
mp4;
set $size $arg_size;
set $blur $arg_blur;
set_md5 $digest $arg_size/$blur/$path;
set $source_file $files/$path;
set $cache_path $cache/$f/$s;
set $cache_file $cache_path/$digest.$ext;
try_files /$f/$s/$digest.$ext /$path @image_server;
}
location /upload/ {
upload_pass @upload;
upload_store $files;
#upload_limit_rate 10m;
upload_set_form_field name $upload_file_name;
upload_set_form_field path $upload_tmp_path;
upload_aggregate_form_field size $upload_file_size;
upload_aggregate_form_field md5 $upload_file_md5;
track_uploads proxied 30s;
}
location /progress/ {
upload_progress_json_output;
report_uploads proxied;
}
location @image_server {
content_by_lua_file $image_handler;
}
location @upload {
proxy_pass http://upload;
proxy_set_header Host $host:$server_port;
}
error_page 500 = @bad_request;
location @bad_request {
return 400;
}
}
map $digest $f {
"~^(?<first>.{2})" $first;
}
map $digest $s {
"~^.{2}(?<second>.{2})" $second;
}
map $arg_size $get_root {
"~^(.*)x(.*)" $cache;
"" $files;
}