diff --git a/conf/alchemy/admin.conf b/conf/alchemy/admin.conf index 34021b3..57ddbba 100644 --- a/conf/alchemy/admin.conf +++ b/conf/alchemy/admin.conf @@ -20,7 +20,9 @@ server { set $upyun_directory "music-room"; set $upyun_domain "https://upyun.alchemy-studio.cn"; set $wx_domain "wx.alchemy-studio.cn"; - set $upt_secret "0D32E581A445404FA4C306709724FA07"; + set $upt_huiwings_secret "C5E4B01EC86A4CE8A84871EA2C826DD1"; + set $upt_moicen_secret "339666FBB93C46D7B00D9F6E790C6C18"; + set $upt_alchemy_secret "0D32E581A445404FA4C306709724FA07"; set $upt_duration 3600; location / { diff --git a/conf/huiwings/admin.conf b/conf/huiwings/admin.conf index 1a9a239..22e55d7 100644 --- a/conf/huiwings/admin.conf +++ b/conf/huiwings/admin.conf @@ -20,7 +20,9 @@ server { set $upyun_directory "music-room"; set $upyun_domain "https://upyun.huiwings.cn"; set $wx_domain "wx.huiwings.cn"; - set $upt_secret "0D32E581A445404FA4C306709724FA07"; + set $upt_huiwings_secret "C5E4B01EC86A4CE8A84871EA2C826DD1"; + set $upt_moicen_secret "339666FBB93C46D7B00D9F6E790C6C18"; + set $upt_alchemy_secret "0D32E581A445404FA4C306709724FA07"; set $upt_duration 3600; location / { diff --git a/conf/moicen/admin.conf b/conf/moicen/admin.conf index 702f08e..feb6f3f 100644 --- a/conf/moicen/admin.conf +++ b/conf/moicen/admin.conf @@ -24,7 +24,9 @@ server { set $upyun_domain "https://upyun.moicen.com"; set $upyun_cdn "https://upyun.moicen.com/"; set $wx_domain "wx.moicen.com"; - set $upt_secret "339666FBB93C46D7B00D9F6E790C6C18"; + set $upt_huiwings_secret "C5E4B01EC86A4CE8A84871EA2C826DD1"; + set $upt_moicen_secret "339666FBB93C46D7B00D9F6E790C6C18"; + set $upt_alchemy_secret "0D32E581A445404FA4C306709724FA07"; set $upt_duration 3600; location / { diff --git a/scripts/lib/upt.lua b/scripts/lib/upt.lua index 245f682..2507f68 100644 --- a/scripts/lib/upt.lua +++ b/scripts/lib/upt.lua @@ -7,8 +7,20 @@ local _M = {} --local strip_path = require("strip_path") --local Upyun = require('upyun') +function host(s) + return (s.."/"):match("://(.-)/") +end + + function _M.upt(uri) - local secret = ngx.var.upt_secret + local hostname = host(uri) + + local upt_table = {} + upt_table["moicen.com"] = ngx.var.upt_moicen_secret, + upt_table["alchemy-studio.cn"] = ngx.var.upt_alchemy_secret, + upt_table["huiwings.cn"] = ngx.var.upt_huiwings_secret + local secret = upt_table[hostname] + ngx.log(ngx.INFO, 'url...' .. uri .. ' host...' .. hostname .. 'secret...' .. secret) local duration = ngx.var.upt_duration local etime = os.time() + duration local sign = ngx.md5(secret .. '&' .. etime .. '&' .. uri)