Comments (5)
我也是这个问题,不知怎么解决?
from ngx_image_thumb.
注意nginx用户组是否有权限写入图片文件
nginx.conf 查看 user 是 哪个用户
from ngx_image_thumb.
例子:http://192.168.1.200:1234/group1/M00/00/04/wKgByFoL5JCAKs5CAAKTjdZqEq4291.jpg_500x400.jpg
server{
listen 1234;
client_max_body_size 100m;
#########使用nginx_image_filter生成缩略图并保存在服务器上############################
#第一步:访问缩略图
location ~ '^/group1/M00/([0-9A-F]{2})/([0-9A-F]{2})/(.*).(jpg|jpeg|png)_([\d]+)x([\d]+).(jpg|jpeg|png)$' {
#直接从缩略图所在目录查找
root /home/fastdfs/cache/;
#如果缩略图不存在,转到生成缩略图的location
if (!-f $request_filename) {
#记录变量
set $width $5;
set $height $6;
set $image_path $1/$2;
set $image_name $3.$4;
#把缩略图的尺寸放入请求参数中
set $image_uri thumb_image/$image_path/$image_name?width=$width&height=$height;
proxy_pass http://127.0.0.1:$server_port/$image_uri;
}
#如果缩略图存在,则直接break,因为缓存缩略图的配置只能写在location的根下
if (-f $request_filename) {
break;
}
#缓存缩略图
#缩略图保存目录
proxy_store /$request_filename;
proxy_store_access user:rw group:rw all:rw;
proxy_temp_path /home/fastdfs/cache_temp/;
proxy_set_header Host $host;
proxy_set_header Content-Type image/jpeg;
}
#第二步:生成缩略图
location /thumb_image {
#原图目录
alias /home/fastdfs/data/;
image_filter resize $arg_width $arg_height;
image_filter_jpeg_quality 25; # 压缩质量
image_filter_buffer 20m; # 如果原始图片大小起过1m,则会报415错误
#不允许外部访问
allow 127.0.0.0/8;
deny all;
}
######使用nginx_image_filter生成缩略图并保存在服务器上
#访问原图:匹配FastDFS,不需要缩略图的,直接使用FastDFS即可
location ~^/group1/M00/..(jpg|jpeg|png)$ {
ngx_fastdfs_module;
}
}
from ngx_image_thumb.
注意nginx用户组是否有权限写入图片文件
nginx.conf 查看 user 是 哪个用户
图片保存的位置呢?下次是不是直接使用?
from ngx_image_thumb.
注意nginx用户组是否有权限写入图片文件
nginx.conf 查看 user 是 哪个用户图片保存的位置呢?下次是不是直接使用?
保存在图片原图目录,如果文件存在,肯定是直接使用的。
404的话,应该是文件权限问题,导致图片无法生成
from ngx_image_thumb.
Related Issues (20)
- 配置后,404,未找到图片 HOT 3
- 一些建议 HOT 1
- ./configure: error: no ./nginx-image-master/config was found HOT 1
- 不支持bmp图片文件,不支持的文件打开后没有关闭
- The example links in readme is not working
- nginx 1.10.2 不能生效 HOT 1
- libgd.so.2 error
- 访问 404 是啥原因? config 有问题吗? 版本号 nginx-1.12 HOT 2
- 缩略图功能可以,水印没有效果 HOT 3
- 会吃光内存导致系统挂掉 HOT 3
- 遇到一个proxy_pass 302 图片的,无法进行图片缩图,是否有大佬解决过
- 有个疑惑,image_backend_server参数是不是只对缩影图有效啊 HOT 2
- when i make nginx with --add-module=/tmp/ngx_image_thumb-master,follow this error: "ngx_http_image_module.c:980:8: error: ignoring return value of 'fread', declared with attribute warn_unused_result [-Werror=unused-result]" HOT 1
- 请求新特性 HOT 5
- 能否加入Last-Modified或者etag
- make errors
- 等比例缩放可否转变为限宽自适应高的模式
- 压缩图片时会旋转图片,这个能不能不旋转
- 代码中存在gd函数内存泄露 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ngx_image_thumb.