-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupload_img_filter.dev.conf
79 lines (77 loc) · 2.39 KB
/
upload_img_filter.dev.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
set $rule_root $document_root;
location ~* /files/(.*)/(.*)\/([0-9a-z]+)\.(jpg|png|jpeg|gif)@(\d+)x(\d+)Q_([rc])$ {
if (-f $request_filename) {
break;
}
set $filepath "files/$1/$2";
set $filename "$3.$4";
set $thumb "$3_$5x$6.$4";
set $width $5;
set $height $6;
set $type $7;
if ( $type = 'r' ){
set $type 'image-resize'; #旋转
}
if ( $type = 'c' ){
set $type 'image-crop'; #剪切
}
if (!-f $document_root/$filepath/$filename) {
return 404;
}
rewrite /files/(.*)/(.*)\/([0-9a-z]+)\.(.*) /imgcache/$1/$2/$thumb;
if (!-f $request_filename) {
proxy_pass $scheme://127.0.0.1:$server_port/$type/$filepath/$filename?width=$width&height=$height;
break;
}
#proxy_store $document_root/imgcache/$1/$2/$thumb;
#proxy_store_access user:rw group:rw all:r;
proxy_set_header Host $host;
expires 10d; # 设置图片过期时间10天
}
location ~* /attachment/(.*)/(.*)\/([0-9a-z]+)\.(jpg|png|jpeg|gif)@(\d+)x(\d+)Q_([rc])$ {
if (-f $request_filename) {
break;
}
set $filepath "attachment/$1/$2";
set $filename "$3.$4";
set $thumb "$3_$5x$6.$4";
set $width $5;
set $height $6;
set $type $7;
if ( $type = 'r' ){
set $type 'image-resize'; #旋转
}
if ( $type = 'c' ){
set $type 'image-crop'; #剪切
}
if (!-f $document_root/$filepath/$filename) {
return 404;
}
rewrite /attachment/(.*)/(.*)\/([0-9a-z]+)\.(.*) /imgcache/$1/$2/$thumb;
if (!-f $request_filename) {
proxy_pass $scheme://127.0.0.1:$server_port/$type/$filepath/$filename?width=$width&height=$height;
break;
}
#proxy_store $document_root/imgcache/$1/$2/$thumb;
#proxy_store_access user:rw group:rw all:r;
proxy_set_header Host $host;
expires 10d; # 设置图片过期时间10天
}
location ^~ /image-resize {
#rewrite /(image-resize)/(.*) /$2 break;
alias $rule_root/;
image_filter resize $arg_width $arg_height;
image_filter_jpeg_quality 75;
image_filter_buffer 20m;
#allow 127.0.0.0/8;
#deny all;
}
location ^~ /image-crop {
#rewrite /(image-crop)/(.*) /$2 break;
alias $rule_root/;
image_filter crop $arg_width $arg_height;
image_filter_jpeg_quality 75;
image_filter_buffer 20m;
#allow 127.0.0.0/8;
#deny all;
}