2018-02-07 和日志相关的Nginx设置


一、Nginx自身的日志配置

$pid: Nginx worker process id

二、Nginx如何传递信息给应用程序

location / {
    proxy_pass http://upstream;
    set $req_id $pid.$msec.$remote_addr.$connection.$connection_requests;
    proxy_set_header X-Request-Id $req_id;
}

然后在应用程序中,获取 request.headers.Get(“X-Request-Id”) 即可

猜你喜欢

转载自blog.csdn.net/sunzhongyuan888/article/details/80370941