-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnginx.conf
95 lines (76 loc) · 2.35 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
worker_processes auto;
worker_shutdown_timeout 65s;
events {
worker_connections 1024;
}
http {
lua_shared_dict prometheus_metrics 10M;
lua_package_path '/etc/nginx/conf.d/lua/?.lua;;';
init_by_lua_block {
prometheus = require("prometheus").init("prometheus_metrics")
metric_requests = prometheus:counter(
"nginx_http_requests_total", "Number of HTTP requests", {"host", "status"})
metric_latency = prometheus:histogram(
"nginx_http_request_duration_seconds", "HTTP request latency", {"host"})
metric_connections = prometheus:gauge(
"nginx_http_connections", "Number of HTTP connections", {"state"})
}
log_by_lua_block {
metric_requests:inc(1, {ngx.var.server_name, ngx.var.status})
metric_latency:observe(tonumber(ngx.var.request_time), {ngx.var.server_name})
}
include mime.types;
default_type application/octet-stream;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 75s;
keepalive_requests 1000000;
gzip on;
server {
listen 8080;
access_log off;
# Allow all RFC 1918 address blocks
# allow 10.0.0.0/8;
# allow 172.16.0.0/12;
# allow 192.168.0.0/16;
# deny all;
location /nginx_status {
stub_status;
}
}
server {
listen 9145;
access_log off;
# Allow all RFC 1918 address blocks
# allow 10.0.0.0/8;
# allow 172.16.0.0/12;
# allow 192.168.0.0/16;
# deny all;
location /metrics {
content_by_lua_block {
metric_connections:set(ngx.var.connections_active, {"active"})
metric_connections:set(ngx.var.connections_reading, {"reading"})
metric_connections:set(ngx.var.connections_writing, {"writing"})
metric_connections:set(ngx.var.connections_waiting, {"waiting"})
prometheus:collect()
}
}
}
server {
listen 80;
access_log /var/log/nginx/access.log combined;
location /200 {
return 200;
}
location /404 {
return 404;
}
location /500 {
return 500;
}
location /501 {
return 501;
}
}
}