Authored by chunhua.zhang

修改IP的获取方式

... ... @@ -214,7 +214,7 @@ function helper_table_contains(t, value)
function limit_ufo_local()
if ngx.var.host == '2.yohobuy.com' or ngx.var.host == 'ufoapi.yohoops.org' or ngx.var.host == '2gray.yohobuy.com' then
local t_local_methods = { } --only allow local access
local t_local_methods = { 'ufo.coupons.send' } --only allow local access
local m = http_request.get_method()
if helper_table_contains(t_local_methods, m) then
local is_local = limit_local:check_local_access()
... ...
... ... @@ -23,27 +23,9 @@ local local_cidr = {
"123.206.73.107"
}
local function get_ip()
local realIp = nil
local xForwardFor = ngx.var.http_x_forwarded_for;
if xForwardFor then
local ips={}
string.gsub(xForwardFor,'[^,]+',function(w) table.insert(ips, w) end )
realIp=ips[#ips]
end
-- if not exist, then setup remote_addr
if realIp == nil then
realIp = ngx.var.remote_addr;
end
if realIp then
realIp=string.gsub(realIp,"%s","")
end
local function get_ip()
local realIp = ngx.var.remote_addr;
return realIp;
end
-- check if ip is local
... ...