fastDFS token有效性配置说明

tracker上关于token的配置/etc/fdfs/http.conf :

# if use token to anti-steal
# default value is false (0)
http.anti_steal.check_token=true


# token TTL (time to live), seconds
# default value is 600
http.anti_steal.token_ttl=60     


# secret key to generate anti-steal token
# this parameter must be set when http.anti_steal.check_token set to true
# the length of the secret key should not exceed 128 bytes
http.anti_steal.secret_key=FastDFS1234567890


# return the content of the file when check token fail
# default value is empty (no file sepecified)
http.anti_steal.token_check_fail=/home/storage/anti-steal.jpg

在tracker中配置token的有效时长为60s

在storage中关于token的配置/etc/fdfs/http.conf :

# if use token to anti-steal
# default value is false (0)
http.anti_steal.check_token=true


# token TTL (time to live), seconds
# default value is 600
http.anti_steal.token_ttl=60


# secret key to generate anti-steal token
# this parameter must be set when http.anti_steal.check_token set to true
# the length of the secret key should not exceed 128 bytes
http.anti_steal.secret_key=FastDFS1234567890


# return the content of the file when check token fail
# default value is empty (no file sepecified)
http.anti_steal.token_check_fail=/home/storage/anti-steal.jpg

在storage中配置token的有效时长为60s

这个只是在fastDFS中配置token的有效时长,其实配置时一般会在nginx上打开cache,即使fastDFS上token的有效时长已过,但在nginx上的cache还有缓存,这时去访问图片等资源时,还是从nginx(tracker上)的缓存中取。我们访问的文件的入口就是nginx,所以会优先查找nginx的cache。如果在tracker上的cache中没找到,再去storage上查找,storage判断token是否失效,如果没失效就返回资源信息,失效就返回配置的错误的页面。

再来看看nginx的cache配置:

proxy_buffer_size 16k;
    proxy_buffers 4 64k;
    proxy_busy_buffers_size 128k;
    proxy_cache_path /fastdfs/cache/nginx/proxy_cache levels=1:2 keys_zone=http-cache:500m max_size=10g inactive=30d;
    proxy_temp_file_write_size 128k; #设置缓存存储路径、存储方式、分配内存大小、磁盘最大空间、缓存期限
    proxy_temp_path /fastdfs/cache/nginx/proxy_cache/tmp;

 location /g2/M00 {
            proxy_next_upstream http_502 http_504 error timeout invalid_header; proxy_cache http-cache;
            proxy_cache_valid 200 304 12h;
            proxy_cache_key $uri$is_args$args;
            proxy_pass http://fdfs_group2;
            expires 30d;
        }

配置为cache的期限为30天,文件会在tracker上保存30天再失效。

PS:

修改了/etc/fdfs/http.conf的配置,即使重启了storage(fdfs_storaged /etc/fdfs/storage.conf restart),但还需要重启nginx才能生效 (/usr/local/nginx/sbin/nginx -s stop;/usr/local/nginx/sbin/nginx)。

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值