nginx HttpSecureLinkModule 过期token验证模块
用途,确认一个链接比如下载pdf,在一定有效期内有用
可以加个用户的权限验证,随便用个密钥和路径和时间戳,生成url串,如果不是在指定时间内访问,则可以自定义错误编码402,407等任意
1.nginx编译的时候需要./configure --prefix=/usr/local/nginx --with-http_secure_link_module
2.确定nginx要保护的目录,配置在nginx.conf中
3.用php可以生成可用链接,先用fastcgi把php跑起来
[root@haoning conf]# cat nginx.confworker_processes 1;events { worker_connections 1024;}http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; server { listen 80; server_name localhost; error_page 500 502 503 504 /50x.html; location = /50x.html { root html; }location /p/ {secure_link $arg_st,$arg_e;secure_link_md5 segredo$uri$arg_e;if ($secure_link = "") {return 402;}if ($secure_link = "0") {return 405;}}location ~ \.php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; set $path_info "/"; set $real_script_name $fastcgi_script_name; if ($fastcgi_script_name ~ "^(.+?\.php)(/.+)$") { set $real_script_name $1; set $path_info $2; } } fastcgi_param SCRIPT_FILENAME $document_root$real_script_name; fastcgi_param script_name $real_script_name; fastcgi_param path_info $path_info; include /usr/local/nginx/conf/fastcgi_params; }}[root@haoning conf]#