• Nginx 深入- secure_link_module 模块


    参考链接

      https://blog.csdn.net/u012525096/article/details/83578321

    1: 资源下载 有效期

    server {
        listen       80;
        server_name  localhost;
    
        #charset koi8-r;
        #access_log  /var/log/nginx/log/host.access.log  main;
        root /opt/app/code;
    
        location / {
            secure_link $arg_md5,$arg_expires;
            secure_link_md5 "$secure_link_expires$uri imooc";  #注意此处的加密串imooc
    
            if ($secure_link = "") {  #若字串不符合
                return 403;
            }
    
            if ($secure_link = "0") {  #若国企返回410 gone
                return 410;
            }
        }
    }

    2: md5.sh

    #!/bin/sh
    #
    #Auth:Jeson@imoocc.com
    servername="120.79.210.194"
    download_file="/download/file.png"
    time_num=$(date -d "2019-07-23 00:00:00" +%s)  #过期时间
    secret_num="imooc"  #此处的加密串 和上面一致
    
    res=$(echo -n "${time_num}${download_file} ${secret_num}"|openssl md5 -binary | openssl base64 | tr +/ -_ | tr -d =)
    
    echo "http://${servername}${download_file}?md5=${res}&expires=${time_num}"

    若执行报错,  -bash: xxx: /bin/sh^M: bad interpreter: No such file or directory

    yum install -y dos2unix
  • 相关阅读:
    K好数
    蓝桥杯 安慰奶牛
    蓝桥杯 节点选择
    模拟链表
    10588
    八数码的 八种境界
    HIT 2051
    概率DP
    数组越界溢出
    FATFS在SD卡里,写入多行数据出的问题
  • 原文地址:https://www.cnblogs.com/eason-d/p/11226022.html
Copyright © 2020-2023  润新知