From 278482ab7253840e4d359f7b91e9b1a44e7332ff Mon Sep 17 00:00:00 2001 From: Karol Wypchlo Date: Mon, 26 Jul 2021 01:54:03 +0200 Subject: [PATCH] os.getenv doesn't take default value in lua --- docker/nginx/conf.d/client.conf | 10 +++++----- docker/nginx/conf.d/include/track-download | 2 +- docker/nginx/conf.d/include/track-registry | 2 +- docker/nginx/conf.d/include/track-upload | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/docker/nginx/conf.d/client.conf b/docker/nginx/conf.d/client.conf index f96d1f62..0b4f4959 100644 --- a/docker/nginx/conf.d/client.conf +++ b/docker/nginx/conf.d/client.conf @@ -273,7 +273,7 @@ server { access_by_lua_block { -- this block runs only when accounts are enabled - if os.getenv("ACCOUNTS_ENABLED", "0") == "0" then return end + if os.getenv("ACCOUNTS_ENABLED") ~= "0" then return end local res = ngx.location.capture("/accounts/user/limits", { copy_all_vars = true }) if res.status == ngx.HTTP_OK then @@ -310,7 +310,7 @@ server { # access_by_lua_block { # -- this block runs only when accounts are enabled - # if os.getenv("ACCOUNTS_ENABLED", "0") == "0" then return end + # if os.getenv("ACCOUNTS_ENABLED") ~= "1" then return end # ngx.var.upload_limit_rate = 5 * 1024 * 1024 # local res = ngx.location.capture("/accounts/user", { copy_all_vars = true }) @@ -352,7 +352,7 @@ server { ngx.req.set_header("SkynetMaxUploadSize", 1073741824) -- this block runs only when accounts are enabled - if os.getenv("ACCOUNTS_ENABLED", "0") == "0" then return end + if os.getenv("ACCOUNTS_ENABLED") ~= "1" then return end -- fetch account limits and set max upload size accordingly local res = ngx.location.capture("/accounts/user/limits", { copy_all_vars = true }) @@ -441,7 +441,7 @@ server { end -- this block runs only when accounts are enabled - if os.getenv("ACCOUNTS_ENABLED", "0") == "0" then return end + if os.getenv("ACCOUNTS_ENABLED") ~= "1" then return end local res = ngx.location.capture("/accounts/user/limits", { copy_all_vars = true }) if res.status == ngx.HTTP_OK then @@ -527,7 +527,7 @@ server { content_by_lua_block { local json = require('cjson') -- this block runs only when accounts are enabled - if os.getenv("ACCOUNTS_ENABLED", "0") == "0" then + if os.getenv("ACCOUNTS_ENABLED") ~= "1" then ngx.say(json.encode{authenticated = false}) return ngx.exit(ngx.HTTP_OK) end diff --git a/docker/nginx/conf.d/include/track-download b/docker/nginx/conf.d/include/track-download index 376568c9..460f9801 100644 --- a/docker/nginx/conf.d/include/track-download +++ b/docker/nginx/conf.d/include/track-download @@ -1,7 +1,7 @@ # register the download in accounts service (cookies should contain jwt) log_by_lua_block { -- this block runs only when accounts are enabled - if os.getenv("ACCOUNTS_ENABLED", "0") == "0" then return end + if os.getenv("ACCOUNTS_ENABLED") ~= "1" then return end local skylink = ngx.header["Skynet-Skylink"] if skylink and ngx.status >= ngx.HTTP_OK and ngx.status < ngx.HTTP_SPECIAL_RESPONSE then diff --git a/docker/nginx/conf.d/include/track-registry b/docker/nginx/conf.d/include/track-registry index a8324f3b..42eff3ac 100644 --- a/docker/nginx/conf.d/include/track-registry +++ b/docker/nginx/conf.d/include/track-registry @@ -1,7 +1,7 @@ # register the registry access in accounts service (cookies should contain jwt) log_by_lua_block { -- this block runs only when accounts are enabled - if os.getenv("ACCOUNTS_ENABLED", "0") == "0" then return end + if os.getenv("ACCOUNTS_ENABLED") ~= "1" then return end if ngx.status == ngx.HTTP_OK or ngx.status == ngx.HTTP_NOT_FOUND then local http = require("socket.http") diff --git a/docker/nginx/conf.d/include/track-upload b/docker/nginx/conf.d/include/track-upload index b95f46e2..ac8a689d 100644 --- a/docker/nginx/conf.d/include/track-upload +++ b/docker/nginx/conf.d/include/track-upload @@ -1,7 +1,7 @@ # register the upload in accounts service (cookies should contain jwt) log_by_lua_block { -- this block runs only when accounts are enabled - if os.getenv("ACCOUNTS_ENABLED", "0") == "0" then return end + if os.getenv("ACCOUNTS_ENABLED") ~= "1" then return end local skylink = ngx.header["Skynet-Skylink"] if skylink and ngx.status >= ngx.HTTP_OK and ngx.status < ngx.HTTP_SPECIAL_RESPONSE then