Nginx : Invalid condition "yes" in nginx.conf - Stack Overflow

I have an environment variable set asvod_enable_encryption = yeswhich I'm attempting to check usin

I have an environment variable set as

vod_enable_encryption = yes

which I'm attempting to check using an If block in nginx.conf.

Nginx isn't able to resolve the condition and throwing the following error :

invalid condition "yes"

The error is thrown at the following 2 location blocks:

The 1st block where The variable is checked is within the location block as follows:

location ~ ^/vod/([^/]+)/.+\.(m3u8|ts)$ {
            vod_mode local;
            vod hls;
            vod_base_url "";

            if ($vod_enable_encryption = "yes") {
            set $stream_uuid $1;
            vod_hls_encryption_method aes-128;
            vod_secret_key "$rtmp_secret $stream_uuid";
            set_hmac_sha1 $sig $rtmp_secret "$cookie_sessionid $stream_uuid";

            if ($http_authorization) {
                set_hmac_sha1 $sig $rtmp_secret "$http_authorization $stream_uuid";
            }

            set_encode_base64 $sig $sig;
            vod_hls_encryption_key_uri "~ ^/vod/([^/]+)/encryption.key?s=$sig";
            }            
        }

The 2nd block where The variable is checked is outside the location block as follows:

if ($vod_enable_encryption = "yes") {
        location ~ ^/vod/([^/]+)/encryption\.key$ {
            vod_mode local;
            vod hls;
            vod_base_url "";

            set $stream_uuid $1;
            set $user_sig $arg_s;
            set_hmac_sha1 $sig $rtmp_secret "$cookie_sessionid $stream_uuid";

            if ($http_authorization) {
                set_hmac_sha1 $sig $rtmp_secret "$http_authorization $stream_uuid";
            }

            set_encode_base64 $sig $sig;

            if ($sig != $user_sig) {
                return 403;
            }

            auth_request /authorize;
            vod_hls_encryption_method aes-128;
            vod_secret_key "$rtmp_secret $stream_uuid";
            }
        }

I'm unable to solve the issue above and spent quite sometime on it. Upon reading more, I realized that One must try avoiding using If conditions in nginx as much as possible. I couldn't figure an alternative implementation. Help appreciated.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745044664a4608021.html

相关推荐

  • Nginx : Invalid condition "yes" in nginx.conf - Stack Overflow

    I have an environment variable set asvod_enable_encryption = yeswhich I'm attempting to check usin

    7小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信