-
Notifications
You must be signed in to change notification settings - Fork 26
/
nginx.conf
59 lines (44 loc) · 1.48 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
51
52
53
54
55
56
57
58
59
daemon off;
worker_processes 2;
error_log /tmp/nginx_error.log warn;
events {
}
http {
# Lua configuration
lua_package_path "$prefix/?.lua;;";
lua_shared_dict log_dict 1M;
server {
listen 8080;
location / {
# Replace with your web application
content_by_lua "
ngx.say('Hello');
";
# this logging code can be added to any existing nginx.conf
log_by_lua '
local logging = require("logging")
local request_time = ngx.now() - ngx.req.start_time()
logging.add_plot(ngx.shared.log_dict, "request_time", request_time)
';
}
}
# log server - print the log generated by our web application
server {
listen 127.0.0.1:6080;
location / {
content_by_lua '
local logging = require("logging")
local count, avg, elapsed_time =
logging.get_plot(ngx.shared.log_dict, "request_time")
local qps = 0
ngx.say("Since last measure:\t", elapsed_time, " secs")
ngx.say("Request Count:\t\t", count)
ngx.say("Average req time:\t", avg, " secs")
if elapsed_time > 0 then
qps = count / elapsed_time
end
ngx.say("Requests per Secs:\t", qps)
';
}
}
}