Toggle navigation
Toggle navigation
This project
Loading...
Sign in
ops
/
yoho-ansible-roles
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
0
Merge Requests
0
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Email Patches
Plain Diff
Browse Files
Authored by
chunhua.zhang
6 years ago
Commit
6c640c6273cf08bc94eb8a65cd4e67dece4b66cf
1 parent
18cae2f7
modify response
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
3 deletions
roles/openresty/files/java-nginx-config/nginx/conf/lua/limit_api_flow.lua
roles/openresty/files/java-nginx-config/nginx/conf/lua/limit_api_flow.lua
View file @
6c640c6
...
...
@@ -74,7 +74,7 @@ function rate_limit()
-- do limit
local
flag
=
limit
(
"yh:nginx:limitflow:"
..
req_uri_method
,
max_per_sencond
)
if
not
flag
then
ngx
.
log
(
ngx
.
ERR
,
"The request is
in
limited :"
..
req_uri_method
)
ngx
.
log
(
ngx
.
ERR
,
"The request is limited :"
..
req_uri_method
)
ngx
.
header
[
"Content-Type"
]
=
"application/json;charset=utf-8"
local
msg
=
'{"code":'
..
err_code
..
',"message":"'
..
err_msg
..
'"}'
ngx
.
say
(
msg
)
...
...
@@ -99,14 +99,19 @@ function is_white()
end
----- check weather ip is in black list
--- be careful when change response(body & header). APP need those to pop up verify toast
function
check_malIp
()
local
cache
=
lua_context
.
mal_ip_cache
local
ip
=
ngx
.
var
.
real_ip
local
exist
=
cache
:
get
(
"yh:mip:"
..
ip
)
if
exist
then
ngx
.
log
(
ngx
.
ERR
,
"The request ip is in blacklist:"
..
ip
)
ngx
.
exit
(
ngx
.
HTTP_FORBIDDEN
)
ngx
.
log
(
ngx
.
ERR
,
"[LimitIPAccess:ip]:"
..
ip
)
ngx
.
header
[
"x-yoho-malicode"
]
=
"10011"
local
rsp
=
'{"code": 10011, "message": ""}'
ngx
.
say
(
rsp
)
ngx
.
exit
(
ngx
.
HTTP_OK
)
end
end
---------end check_malIp()-----------
...
...
Please
register
or
login
to post a comment