-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnginx.conf
50 lines (41 loc) · 1.2 KB
/
nginx.conf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
worker_processes 1;
events {
worker_connections 1024;
}
http {
lua_shared_dict log_dict 10m;
server {
listen 80;
# Example of logging stats on 200s.
location = / {
# Force an HTTP response.
content_by_lua_block {
ngx.say("hi")
}
# This runs after the HTTP response is sent.
log_by_lua_block {
local log_dict = ngx.shared.log_dict
log_dict:incr(ngx.status, 1, 0)
}
}
# Example of logging stats on 404s.
error_page 404 /error;
location = /error {
log_by_lua_block {
local log_dict = ngx.shared.log_dict
log_dict:incr(ngx.status, 1, 0)
}
internal;
}
# Example of reading back from dictionary.
location /report {
content_by_lua_block {
local log_dict = ngx.shared.log_dict
local status = log_dict:get("200") or 0
ngx.say("200 count: ", status)
local status = log_dict:get("404") or 0
ngx.say("404 count: ", status)
}
}
}
}