Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
edetmt
/
nginx-lua
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 8e9a43a8
authored
Apr 24, 2020
by
edetmt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed logs
1 parent
a3e24db4
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
20 deletions
config.lua
lib.lua
config.lua
View file @
8e9a43a
...
@@ -40,16 +40,11 @@ config_output_html=[[
...
@@ -40,16 +40,11 @@ config_output_html=[[
<head>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Language" content="zh-cn" />
<meta http-equiv="Content-Language" content="zh-cn" />
<title>
网站waf防火墙
</title>
<title>
block info
</title>
</head>
</head>
<body>
<body>
<h1 align="center"> 网站waf防火墙 </h1>
<h1 align="center"> 403 forbidden </h1>
<br/>
<h4 align="center">由于你访问的URL可能对网站造成安全威胁,访问被阻断</h4>
<br/><br/><br/><br/><br/>
<img src="https://oscimg.oschina.net/oscnet/c91b537ae2dcdabca9bab58fc3807f74259.jpg">
<hr/>
</body>
</body>
</html>
</html>
...
...
lib.lua
View file @
8e9a43a
...
@@ -48,25 +48,14 @@ end
...
@@ -48,25 +48,14 @@ end
--WAF log record for json,(use logstash codec => json)
--WAF log record for json,(use logstash codec => json)
function
log_record
(
method
,
url
,
data
,
ruletag
)
function
log_record
(
method
,
url
,
data
,
ruletag
)
local
cjson
=
require
(
"cjson"
)
local
io
=
require
'io'
local
io
=
require
'io'
local
LOG_PATH
=
config_log_dir
local
LOG_PATH
=
config_log_dir
local
CLIENT_IP
=
get_client_ip
()
local
CLIENT_IP
=
get_client_ip
()
local
USER_AGENT
=
get_user_agent
()
local
USER_AGENT
=
get_user_agent
()
local
SERVER_NAME
=
ngx
.
var
.
server_name
local
SERVER_NAME
=
ngx
.
var
.
server_name
local
LOCAL_TIME
=
ngx
.
localtime
()
local
LOCAL_TIME
=
ngx
.
localtime
()
local
log_json_obj
=
{
local
log_json_obj
=
CLIENT_IP
..
" "
..
LOCAL_TIME
..
" "
..
method
..
" "
..
url
..
" "
..
config_set_ip_addr
..
" "
..
SERVER_NAME
..
" "
..
USER_AGENT
..
" "
..
data
..
" "
..
ruletag
ip_from
=
config_set_ip_addr
,
local
LOG_LINE
=
log_json_obj
client_ip
=
CLIENT_IP
,
local_time
=
LOCAL_TIME
,
server_name
=
SERVER_NAME
,
user_agent
=
USER_AGENT
,
attack_method
=
method
,
req_url
=
url
,
req_data
=
data
,
rule_tag
=
ruletag
,
}
local
LOG_LINE
=
cjson
.
encode
(
log_json_obj
)
--local LOG_NAME = LOG_PATH..'/'..ngx.today().."_waf.log"
--local LOG_NAME = LOG_PATH..'/'..ngx.today().."_waf.log"
local
LOG_NAME
=
LOG_PATH
..
'/'
..
"waf.log"
local
LOG_NAME
=
LOG_PATH
..
'/'
..
"waf.log"
local
file
=
io.open
(
LOG_NAME
,
"a"
)
local
file
=
io.open
(
LOG_NAME
,
"a"
)
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment