diff options
author | HuabingZhao <zhao.huabing@zte.com.cn> | 2016-08-25 10:17:35 +0800 |
---|---|---|
committer | HuabingZhao <zhao.huabing@zte.com.cn> | 2016-08-25 10:24:54 +0800 |
commit | 8597cf5e116012c038e83f763a816ca106cad4d2 (patch) | |
tree | 4f6671079047db1f565060dcce4bf2607856cf68 /msb-core/openresty-ext/src/assembly/resources/openresty/nginx/luaext/auth.lua | |
parent | eb9df7aa9e268192dd68a46af4576671b17adcf9 (diff) |
Solve api gateway issue
Change-Id: I88fedc04faaf4d799b9dbf4c306aa073cabd6218
Signed-off-by: HuabingZhao <zhao.huabing@zte.com.cn>
Diffstat (limited to 'msb-core/openresty-ext/src/assembly/resources/openresty/nginx/luaext/auth.lua')
-rw-r--r-- | msb-core/openresty-ext/src/assembly/resources/openresty/nginx/luaext/auth.lua | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/msb-core/openresty-ext/src/assembly/resources/openresty/nginx/luaext/auth.lua b/msb-core/openresty-ext/src/assembly/resources/openresty/nginx/luaext/auth.lua new file mode 100644 index 0000000..067c277 --- /dev/null +++ b/msb-core/openresty-ext/src/assembly/resources/openresty/nginx/luaext/auth.lua @@ -0,0 +1,15 @@ +local cache = ngx.shared.ceryx +local client_ip = ngx.var.remote_addr +local host = ngx.var.host +if client_ip == '127.0.0.1' or client_ip == host or client_ip == ngx.var.server_addr then + return +end +local succ, err, forcible = cache:replace(client_ip, "place_holder", 3600) +if not succ then + if err == 'not found' then + ngx.log(ngx.WARN, "access record not found for "..client_ip) + ngx.exit(401) + else + ngx.log(ngx.WARN, err) + end +end
\ No newline at end of file |