###nginx日誌格式案例(一)html
log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"';
【ngx_http_proxy_module中】 $proxy_add_x_forwarded_for 將$remote_addr變量值添加在客戶端「X-Forwarded-For」請求頭的後面,並以逗號分隔。 若是客戶端請求未攜帶「X-Forwarded-For」請求頭,$proxy_add_x_forwarded_for變量值將與$remote_addr變量相同。
###nginx日誌格式案例(二)nginx
log_format main '$host ' //「Host」請求頭的值,若是沒有該請求頭,則爲與請求對應的虛擬主機的首要主機名 '$server_addr ' //接受請求的服務器地址 '$remote_addr ' //客戶端IP地址 '- ' '"$time_local" ' '$status ' '$body_bytes_sent ' '$request_time ' //請求處理的時間,單位爲秒,精度是毫秒(1.3.9, 1.2.6);請求處理時間從由客戶端接收到第一個字節開始計算 '"$http_referer" ' //告訴服務器我是從哪一個頁面連接過來的 '"$request" ' '"$http_user_agent" ' '$pid'; //處理請求的nginx進程id
參考1瀏覽器