fastdfs 開啓 token 防盜鏈

環境: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服務器時間不要相差分鐘級。

相關文章
相關標籤/搜索