-
Notifications
You must be signed in to change notification settings - Fork 67
/
fdfs.conf
59 lines (50 loc) · 2.7 KB
/
fdfs.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
server{
listen 80;
server_name fdfs.xxx.com;
set $img_thumbnail_root /opt/fastdfs/thumb; #set thumb path
set $img_file $img_thumbnail_root$uri; #thumb file
# like:/pic/M00/xx/xx/xx.jpg_100-.jpg or /pic/M00/xx/xx/xx.jpg_-100.jpg
location ~* ^(\/(\w+)(\/M00)(.+\.(jpg|jpeg|gif|png)))_((\d+\-)|(\-\d+))\.(jpg|jpeg|gif|png)$ {
root $img_thumbnail_root; # root path for croped img
set $fdfs_group_root /opt/fastdfs/$2/store0/data; #set fastdfs group path $2
if (!-f $img_file) { # if thumb file not exists
add_header X-Powered-By 'Nginx+Lua+GraphicsMagick By Yanue'; # header for test
add_header file-path $request_filename; # header for test
set $request_filepath $fdfs_group_root$4; # origin_img full path:/document_root/1.gif
set $img_size $6; # img width or height size depends on uri : img size like "-100" or "100-", "-" means auto size
set $img_ext $5; # file ext
content_by_lua_file /etc/nginx/lua/autoSize.lua; # load auto width or height crop Lua file
}
}
# like:/pic/M00/xx/xx/xx.jpg_200x100.jpg
location ~* ^(\/(\w+)(\/M00)(.+\.(jpg|jpeg|gif|png))_(\d+)+x(\d+)+\.(jpg|jpeg|gif|png))$ {
root $img_thumbnail_root; # root path for croped img
set $fdfs_group_root /opt/fastdfs/$2/store0/data; #set fastdfs group path $2
if (!-f $img_file) { # if thumb file not exists
add_header X-Powered-By 'Nginx+Lua+GraphicsMagick By Yanue'; # header for test
add_header file-path $request_filename; # header for test
set $request_filepath $fdfs_group_root$4; # real file path
set $img_width $6; # img width
set $img_height $7; # img height
set $img_ext $5; # file ext
content_by_lua_file /etc/nginx/lua/cropSize.lua; # load crop Lua file
}
}
location /pic/M00 {
# add support for img which has query params,
# like: xxx.jpg?a=b&c=d_750x750.jpg
if ($args ~* "^([^_]+)_(\d+)+x(\d+)+\.(jpg|jpeg|gif|png)$"){
set $w $2;
set $h $3;
set $img_ext $4;
# rewrite ^\?(.*)$ _${w}x${h}.$img_ext? last;
rewrite ([^.]*).(jpg|jpeg|png|gif)$ $1.$2_${w}x${h}.$img_ext? permanent;
}
alias /opt/fastdfs/pic/store0/data;
ngx_fastdfs_module;
}
location = /favicon.ico {
log_not_found off;
access_log off;
}
}