Nginx图片处理
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;
}
}