fix load-balancer example and add server_name to cache keys when required
This commit is contained in:
parent
66921b0075
commit
39ace81755
|
@ -18,7 +18,7 @@ services:
|
|||
- REVERSE_PROXY_URL=/
|
||||
- REVERSE_PROXY_HOST=http://app
|
||||
- |
|
||||
CUSTOM_CONF_HTTP_upstream.conf=
|
||||
CUSTOM_CONF_HTTP_upstream=
|
||||
upstream app {
|
||||
server app1:80;
|
||||
server app2:80;
|
||||
|
|
|
@ -162,7 +162,7 @@ function blacklist:kind_to_ele(kind)
|
|||
end
|
||||
|
||||
function blacklist:is_in_cache(ele)
|
||||
local ok, data = self.cachestore:get("plugin_blacklist_" .. ele)
|
||||
local ok, data = self.cachestore:get("plugin_blacklist_" .. ngx.ctx.bw.server_name .. ele)
|
||||
if not ok then
|
||||
return false, data
|
||||
end
|
||||
|
@ -170,7 +170,7 @@ function blacklist:is_in_cache(ele)
|
|||
end
|
||||
|
||||
function blacklist:add_to_cache(ele, value)
|
||||
local ok, err = self.cachestore:set("plugin_blacklist_" .. ele, value, 86400)
|
||||
local ok, err = self.cachestore:set("plugin_blacklist_" .. ngx.ctx.bw.server_name .. ele, value, 86400)
|
||||
if not ok then
|
||||
return false, err
|
||||
end
|
||||
|
|
|
@ -92,7 +92,7 @@ function country:preread()
|
|||
end
|
||||
|
||||
function country:is_in_cache(ip)
|
||||
local ok, data = self.cachestore:get("plugin_country_cache_" .. ip)
|
||||
local ok, data = self.cachestore:get("plugin_country_cache_" .. ngx.ctx.bw.server_name .. ip)
|
||||
if not ok then
|
||||
return false, data
|
||||
end
|
||||
|
@ -100,7 +100,7 @@ function country:is_in_cache(ip)
|
|||
end
|
||||
|
||||
function country:add_to_cache(ip, country, result)
|
||||
local ok, err = self.cachestore:set("plugin_country_cache_" .. ip, cjson.encode({country = country, result = result}), 86400)
|
||||
local ok, err = self.cachestore:set("plugin_country_cache_" .. ngx.ctx.bw.server_name .. ip, cjson.encode({country = country, result = result}), 86400)
|
||||
if not ok then
|
||||
return false, err
|
||||
end
|
||||
|
|
|
@ -231,7 +231,7 @@ function greylist:is_greylisted_ua()
|
|||
end
|
||||
|
||||
function greylist:is_in_cache(ele)
|
||||
local ok, data = self.cachestore:get("plugin_greylist_" .. ele)
|
||||
local ok, data = self.cachestore:get("plugin_greylist_" .. ngx.ctx.bw.server_name .. ele)
|
||||
if not ok then
|
||||
return false, data
|
||||
end
|
||||
|
@ -239,7 +239,7 @@ function greylist:is_in_cache(ele)
|
|||
end
|
||||
|
||||
function greylist:add_to_cache(ele, value)
|
||||
local ok, err = self.cachestore:set("plugin_greylist_" .. ele, value, 86400)
|
||||
local ok, err = self.cachestore:set("plugin_greylist_" .. ngx.ctx.bw.server_name .. ele, value, 86400)
|
||||
if not ok then
|
||||
return false, err
|
||||
end
|
||||
|
|
|
@ -189,7 +189,7 @@ function whitelist:check_cache()
|
|||
end
|
||||
|
||||
function whitelist:is_in_cache(ele)
|
||||
local ok, data = self.cachestore:get("plugin_whitelist_" .. ele)
|
||||
local ok, data = self.cachestore:get("plugin_whitelist_" .. ngx.ctx.bw.server_name .. ele)
|
||||
if not ok then
|
||||
return false, data
|
||||
end
|
||||
|
@ -197,7 +197,7 @@ function whitelist:is_in_cache(ele)
|
|||
end
|
||||
|
||||
function whitelist:add_to_cache(ele, value)
|
||||
local ok, err = self.cachestore:set("plugin_whitelist_" .. ele, value, 86400)
|
||||
local ok, err = self.cachestore:set("plugin_whitelist_" .. ngx.ctx.bw.server_name .. ele, value, 86400)
|
||||
if not ok then
|
||||
return false, err
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue