nginx接口安全验证模块ngx_http_secure_link_module

location配置

`
location ~ ^/v1/(reward|exchange)/ {
set $channel_name $cookie_channel_name;
secure_link $arg_sign,$arg_et;
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 = "") {
            set $check_status 504;
        }
        if ($arg_version_name = "1.1.4.7") {
            set $check_status 200;
        }
        if ($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 / {
        add_header Access-Control-Allow-Origin *;
        add_header Access-Control-Allow-Methods ‘GET, POST, OPTIONS‘;
        add_header Access-Control-Allow-Headers ‘DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization‘;

        proxy_pass http://127.0.0.1:10001;
    }

`

相关推荐