location ~* /file/traffic/download/img/2/(.+)/(.+)/(.+)_(.+)x(.+).(jpg|gif|png) {
set $h $4;
set $w $5;
#根据给定的长宽生成缩略图
image_filter resize $h $w;
#原图最大2M,要裁剪的图片超过2M返回415错误,需要调节参数image_filter_buffer
image_filter_buffer 2M;
rewrite /file/traffic/download/img/2/(.+)/(.+)/(.+)_(.+)x(.+).(jpg|gif|png) /resize/file/traffic/download/img/2/$1/$2/$3.$6;
}
location ^~ /resize/file/traffic/download/img/2/ {
image_filter resize $h $w;
alias /opt/yqjj/data/file/traffic/download/img/2/;
allow all;
}
location /file/traffic/download/img/2 {
root /opt/yqjj/data;
}
}
一 常见问题
1 too big response: while sending response to client
查看nginx日志,发现错误。在使用image_filter的模块中添加image_filter_buffer。