环境:php
fastdfs nginx
nginx + ngx_fastdfs_module服务器
php+fastdfs_php扩展函数
开启token令牌:url
vi /etc/fdfs/http.conftoken
#开启ip
http.anti_steal.check_token=trueast
#密钥module
http.anti_steal.secret_key=123456 cli
重启nginx
php中,经过fastdfs_http_gen_token()函数生成$token,例如:
$ts=time();//当前时间戳
$token=fastdfs_http_gen_token('M00/00/00/Ss_0rVGSABmAEZ1QAAC6WE5-JkI695.zip',$ts);
而后url形如:
http://localhost/M00/00/00/Ss_0rVGSABmAEZ1QAAC6WE5-JkI695.zip?token=8de0e6554be69d0b9385faad654c4364&ts=1368589809
这样服务端就能够自动根据 token , ts ,以及设置的密钥来验证合法性。密钥过时时间在http.conf里设置。
问题:
token老是验证失败,须要检查以下:
1.fastdfs_http_gen_token($file_name,$timestmp);中$file_name 不要包含group_name
2.你是否忘记设置客户端对应的配置文件里,也有一个密钥,要求跟http.conf中的一直,好比php.ini中的fastdfs_client.http.anti_steal_secret_key参数。
3.检查你的fdfs服务器和client服务器时间不要相差分钟级。