首頁  >  文章  >  後端開發  >  Nginx 記錄請求分發日誌設置

Nginx 記錄請求分發日誌設置

WBOY
WBOY原創
2016-07-29 08:58:021710瀏覽


在nginx接收到請求之後, 需把請求分發到後端WEB服務集群.

在這裡需要記錄分發日誌, 來分析後端每台WEB伺服器處理的請求數目.在日誌顯示的資訊為:

<pre name="code" class="python">http {
log_format  main  
  ' $remote_user [$time_local]  $http_x_Forwarded_for $remote_addr  $request '
 '$http_x_forwarded_for '                     
 '$upstream_addr '                      
 'ups_resp_time: $upstream_response_time '                      
 'request_time: $request_time';

access_log  logs/access.log  main;

server{}
...
}


全部設定檔nginx.conf.

 - [31/May/2013:00:01:03 -0700]  - xxx.ip.addr.xxx  GET /portal/index.html HTTP/1.1 - 192.168.100.15:8188 ups_resp_time: 0.010 request_time: 0.011
 - [31/May/2013:00:01:03 -0700]  - xxx.ip.addr.xxx  GET /portal/index.html HTTP/1.1 - 192.168.100.16:8188 ups_resp_time: 0.006 request_time: 0.006
 - [31/May/2013:00:01:03 -0700]  - xxx.ip.addr.xxx  GET /portal/index.html HTTP/1.1 - 192.168.100.15:8188 ups_resp_time: 0.013 request_time: 0.013
 - [31/May/2013:00:01:03 -0700]  - xxx.ip.addr.xxx  GET /portal/index.html HTTP/1.1 - 192.168.100.17:8188 ups_resp_time: 0.003 request_time: 0.003
 - [31/May/2013:00:01:03 -0700]  - xxx.ip.addr.xxx  GET /portal/index.html HTTP/1.1 - 192.168.100.18:8188 ups_resp_time: 0.004 request_time: 0.004
 - [31/May/2013:00:01:03 -0700]  - xxx.ip.addr.xxx  GET /portal/index.html HTTP/1.1 - 192.168.100.15:8188 ups_resp_time: 0.012 request_time: 0.013
 - [31/May/2013:00:01:03 -0700]  - xxx.ip.addr.xxx  GET /portal/index.html HTTP/1.1 - 192.168.100.18:8188 ups_resp_time: 0.005 request_time: 0.005
 - [31/May/2013:00:01:03 -0700]  - xxx.ip.addr.xxx  GET /portal/index.html HTTP/1.1 - 192.168.100.16:8188 ups_resp_time: 0.011 request_time: 0.011
 - [31/May/2013:00:01:03 -0700]  - xxx.ip.addr.xxx  GET /portal/index.html HTTP/1.1 - 192.168.100.15:8188 ups_resp_time: 0.447 request_time: 0.759

nginx st 以上就介紹了Nginx 記錄請求分發日誌設置,包括了方面的內容,希望對PHP教程有興趣的朋友有所幫助。
陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn