14. Nginx Secure Link

用于校验资源请求的合法性

  server {
        listen 3300;
        server_name www.siguoya.name;
        root /usr/local/nginx/1.12.1/html;
        location / {
            secure_link $arg_md5,$arg_expires;
            secure_link_md5 "$secure_link_expires$uri siguoya";
            if ($secure_link = "") {
                return 403;
            }
            if ($secure_link = "0") {
                return 410;
            }
        }
    }

如果是访问 http://www.siguoya.name:3300/index.html?expires=111 的话,md5 值的 shell 计算方法如下:

echo -n '111/index.html siguoya' | openssl md5 -binary | openssl base64 | tr +/ -_ | tr -d =
链接 响应码
http://www.siguoya.name:3300/index.html?expires=111&md5=111 403,md5不正确,时间过期
http://www.siguoya.name:3300/index.html?expires=2147483647&md5=111 403,md5不正确,时间未过期
http://www.siguoya.name:3300/index.html?expires=111&md5=cLdY2ROg2kZDD0xkWaJ8TQ 410,md5正确,时间过期
http://www.siguoya.name:3300/index.html?expires=2147483647&md5=GfmT6Hj3U55xfQJ3aNqjfQ 200,md5正确,时间未过期

专题阅读

posted on 2020-03-30 18:40  思过崖灬  阅读(324)  评论(0编辑  收藏  举报

导航