标签:htm err nop gif not home $2 原来 网站
最近公司商城的图片严重影响到了网站的正常访问,为了尽快解决这个问题,采用 图片动态生成的处理方式。这里用到了nginx的 http_image_filter_module 模块,安装nginx的时候需要配置上 --with-http_image_filter_module
同时,把原来放在项目跟目录下的图片通过 rsync + inotify 配置 对图片进行同步,同步到图片服务器
nginx 配置:
server {
listen 80;
server_name static.xxxx.com;
location ~* /uploads/(.*)_(\d+)x(\d+)\.(jpeg|jpg|png|gif)$ {
root /home/wwwroot;
set $h $2;
set $w $3;
if ($h = ‘0‘){
rewrite /uploads/(.*)_(\d+)x(\d+)\.(jpeg|jpg|gif|png)$ /uploads/$1.$4 last;
}
if ($w = ‘0‘) {
rewrite /uploads/(.*)_(\d+)x(\d+)\.(jpeg|jpg|gif|png)$ /uploads/$1.$4 last;
}
#生成缩略图
image_filter resize $h $w;
image_filter_buffer 5M;
error_page 415 /uploads/nopicture.png;
try_files /uploads/$1.$4 /uploads/nopicture.jpg;
}
location ~* /uploads/(\d+){
root /home/wwwroot;
}
# redirect server error pages to the static page /50x.html
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
#access_log /home/wwwlogs/static.cwbbc.com.log access;
}
标签:htm err nop gif not home $2 原来 网站
原文地址:https://www.cnblogs.com/murenhui/p/8953834.html