Environment:
Fastdfs
Nginx + ngx_fastdfs_module
PHP + fastdfs_php Extension
Enable token:
VI/etc/fdfs/HTTP. conf
# Enable
HTTP. anti_steal.check_token = true
# Key
HTTP. anti_steal.secret_key = 123456
Restart nginx
In PHP, $ token is generated through the fastdfs_http_gen_token () function, for example:
$ Ts = Time (); // current Timestamp
$ Token = fastdfs_http_gen_token ('m00/00/00/Ss_0rVGSABmAEZ1QAAC6WE5-JkI695.zip ', $ TS );
Then the URL is like:
Http: // localhost/m00/00/00/Ss_0rVGSABmAEZ1QAAC6WE5-JkI695.zip? Token = 8de0e6554be69d0b9425faad654c4364 & TS = 1368589809
In this way, the server can automatically verify validity Based on the token, ts, And the set key. Set the key expiration time in HTTP. conf.
Problem:
The token always fails to be verified. Check the following:
1. fastdfs_http_gen_token ($ file_name, $ timestmp); $ file_name must not contain group_name
2. Do you forget to set a key in the configuration file corresponding to the client, which must be consistent with that in HTTP. conf, such as the fastdfs_client.http.anti_steal_secret_key parameter in PHP. ini.
3. Check that the time between your fdfs server and the client server does not differ by minutes.
Fastdfs enables token anti-leech Protection