Add response header and request header to access.log
of nginx
.
$upstream_http_resonseHeaderName
$http_requestHeaderName
log_format addHeaderlog '$remote_addr - $remote_user [$time_local] ' '"$request" $status $body_bytes_sent ' '"$http_referer" "$http_user_agent" "$http_x_forwarded_for" "$request_body" "$http_Authorization" "$http_x_duid" "$http_x_ver" "$upstream_http_x_rqid"';
|
reference
nginx forward nginx
conf of server nginx
/etc/nginx/sites-enabled/back.conf
server { listen 999; root /usr/share/nginx/html; index index.html index.htm; access_log /var/log/nginx/back.log addHeaderlog ; add_header x-rqid testXRqidResponse; server_name 10.10.10.47; location / { try_files $uri $uri/ =404; } }
|
conf of balance nginx
/etc/nginx/sites-enabled/front.conf
upstream localhost_django{ server 10.10.10.37:999; } server { listen 99; server_name 10.10.10.37; access_log /var/log/nginx/front-default.log client; access_log /var/log/nginx/front-addHeaders.log addHeaderlog ; location / { root html; index index.html index.htm; proxy_pass http://localhost_django; }}
|
logging POST request
add $request_body
in log_format