-
Notifications
You must be signed in to change notification settings - Fork 8
/
nginx.conf
98 lines (84 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
96
97
98
worker_processes 1;
error_log logs/error.log info;
pid logs/nginx.pid;
# load_module modules/ngx_http_response_body_module.so;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" $status "$err" "$response_body"';
log_format test '$remote_addr - $remote_user [$time_local] "$request" $status "$err" "$test_response_body"';
access_log logs/access.log main;
upstream test {
server 127.0.0.1:7777;
}
map $status $cond {
500 1;
401 1;
403 1;
404 1;
default 0;
}
capture_response_body off;
capture_response_body_buffer_size 1m;
capture_response_body_buffer_size_min 4k;
capture_response_body_buffer_size_multiplier 2;
capture_response_body_if $cond 1;
capture_response_body_if_latency_more 1s;
map $response_body $err {
~\"error\":\"(?<e>.+)\" $e;
default "";
}
server {
listen 7777;
location / {
echo_sleep 1.5;
echo '0000000000';
}
location /500 {
echo_status 500;
echo '{"error":"internal error"}';
}
location /200 {
echo OK;
}
location /404 {
echo_status 404;
echo '404';
}
location /header_in {
echo 'OK';
}
location /header_out {
add_header X-Trace-Response 1;
echo 'OK';
}
location /test {
add_header X-Trace-Response 1;
echo 'OK';
}
}
server {
capture_response_body on;
listen 8888;
location / {
proxy_pass http://test;
}
location /header_in {
capture_response_body_if $http_x_trace *;
proxy_pass http://test;
}
location /header_out {
capture_response_body_if $sent_http_x_trace_response *;
proxy_pass http://test;
}
location /test {
access_log logs/test.log test;
capture_response_body_var test_response_body;
capture_response_body_if $sent_http_x_trace_response 1;
proxy_pass http://test;
}
}
}