nginx接口安全驗證模塊ngx_http_secure_link_module


location配置

location ~ ^/v1/(apple|banana)/ {  #uri以v1/apple或者v1/banana開頭的,走以下的邏輯,驗證簽名
            set $channel_name $cookie_channel_name;  # 設置channel_name變量為cookie中的channel_name的值
            secure_link $arg_sign,$arg_expire;  # arg中的簽名和過期時間
            secure_link_md5 "$uri $arg_version_name $channel_name $arg_et  gohell";

            set $check_status "";

            # checksum
            if ($secure_link = "") {
                set $check_status 403;
            }
            if ($arg_nonce_str = "") {
                set $check_status 200;
            }
            # expire
            if ($secure_link = "0") {
                set $check_status 410;
            }
            if ($arg_sign = "") {  # arg中無簽名的直接返回504
                set $check_status 504;
            }
            if ($arg_version_name = "1.1.4.7") {  # arg中有version_name參數值為1.1.4.7的不驗證簽名
                set $check_status 200;
            }
            if ($arg_mmmm != "") {  # arg中有mmmm參數的不驗證簽名
                set $check_status 200;
            }
            if ($check_status = 403) {
                return 403;
            }
            if ($check_status = 410) {
                return 410;
            }
            if ($check_status = 504) {
                return 504;
            }

            proxy_pass http://127.0.0.1:10001;
        }


        location / {
            proxy_pass http://127.0.0.1:10001;
        }


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM