前言
在数据平台事业部文件服务使用到fastDFS
部署&配置
1.部署请参考
- https://blog.csdn.net/IT8421/article/details/89322296
- 配置文件
配置文件如下,开启防盗链
http.default_content_type = application/octet-stream
http.mime_types_filename=mime.types
http.anti_steal.check_token=false
#多久失效
http.anti_steal.token_ttl=900
#密钥
http.anti_steal.secret_key=FastDFS1234567890
http.anti_steal.token_check_fail=/home/yuqing/fastdfs/conf/anti-steal.jpg
开启回写url
location / {
root html;
index index.html index.htm;
}
location ~/group[0-9] {
ngx_fastdfs_module;
if ($arg_fn ~ "^(.+)") {
add_header Content-Type application/x-download;
add_header Content-Disposition "attachment;filename=$arg_fn";
}
}
问题&解决方案
1.get请求路径太长fastDFS nginx处理的时候报错
[2019-10-30 16:54:42] ERROR - file: /home/hadoop/fastdfs-nginx-module
/src/common.c, line: 614, uri length: 264 is too long, >= 256
- 修改硬编码
cat /home/hadoop/fastdfs-nginx-module/src/common.c
把uri[1024] 修改为 uri[10240] 重新编译nginx,重新启动即可解决
总结
开启防止token防止盗链,对数据保护起到了一定的作用.