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
950e539fb5f54cd8392e9cc4e90e6715db1f631d
1 parent
422e530b
add
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
5 deletions
roles/openresty/files/java-nginx-config/nginx/conf/lua/limit_local_access.lua
roles/openresty/files/java-nginx-config/nginx/conf/lua/limit_local_access.lua
View file @
950e539
...
...
@@ -13,7 +13,14 @@ local local_cidr = {
-- check if ip is local
-- depends on ngx.real_ip from setup.lua
function
check_local_access
(
ip
)
function
check_local_access
()
-- read ip from ngx.real_ip
local
ip
=
ngx
.
real_ip
if
(
ngx
.
real_ip
==
nil
or
ngx
.
real_ip
==
''
)
then
return
end
local
is_local_ip
=
false
for
i
=
1
,
#
local_cidr
do
local
is_in_cidr
=
iptool
:
pcall_check_ip_in_ipblock
(
ip
,
local_cidr
[
i
],
false
)
...
...
@@ -23,10 +30,6 @@ function check_local_access(ip)
end
end
if
(
ngx
.
real_ip
==
nil
or
ngx
.
real_ip
==
''
)
then
return
end
if
not
is_local_ip
then
ngx
.
exit
(
403
);
return
...
...
Please
register
or
login
to post a comment