server {
# ...此处省略N行配置
# example: /thumb/[md5].png_300x187.png
location ~ "/thumb/([0-9a-f]{32}\.(png|jpg|gif))_(\d+|-)x(\d+|-)\.(png|jpg|gif)$" {
access_log off;
set $image
server {
# ...此处省略N行配置
# example: /thumb/[md5].png_300x187.png
location ~ "/thumb/([0-9a-f]{32}\.(png|jpg|gif))_(\d+|-)x(\d+|-)\.(png|jpg|gif)$" {
access_log off;
set $image $1;
set $width $3;
set $height $4;
# 建议应用try_files取代if
try_files /thumb/$image =404;
image_filter resize $width $height;
image_filter_buffer 10M;
# 只会在阅读器端缓存,若要在服务器端缓存,可采取proxy的计划(此处没有给出,可自行google)
expires 7d;
}
}
;
set $width ;
set $height ;
# 建议应用try_files取代if
try_files /thumb/$image =404;
image_filter resize $width $height;
image_filter_buffer 10M;
# 只会在阅读器端缓存,若要在服务器端缓存,可采取proxy的计划(此处没有给出,可自行google)
expires 7d;
}
}server {
# ...此处省略N行配置
# example: