Nginx ngx_http_secure_link_module模块能够检查请求链接的权限以及是否过期,多用于下载服务器防盗链。
原理
1)加密串与过期时间作为url中的参数
2)nginx服务器接收到了过期时间,也使用过期时间、配置里密钥、文件uri生成加密串
3)计算的加密串与url传递的加密串进行对比
开启ngx_http_secure_link_module
./configure --with-http_secure_link_module #编译nginx时加入
该模块提供两种工作模式:
模式一
通过配置 secure_link
,secure_link_md5
,可实现对链接进行权限以及过期检查判断的功能。
secure_link
语法
语法 : secure_link expression;
默认值: 无
配置段:http, server, location说明