location /static/ {
root /var/www/;
try_files $uri /static/img/default.jpg;
}
参考:https://serverfault.com/questions/395128/serving-a-default-image-with-nginx
Nginx默认图片配置
本文介绍如何使用Nginx配置静态文件路径,并在请求的文件不存在时返回默认图片。通过设置root路径和try_files指令实现这一功能。
location /static/ {
root /var/www/;
try_files $uri /static/img/default.jpg;
}
参考:https://serverfault.com/questions/395128/serving-a-default-image-with-nginx
358
1163

被折叠的 条评论
为什么被折叠?