1、配置檔案
#vim /usr/local/nginx/conf/nginx.conf
log_format access '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" $http_x_forwarded_for';
include /usr/local/nginx/conf/vhost/*.conf;
2、vhost中配置
#vim /usr/local/nginx/conf/vhost/www.abc.com.conf
server
{
listen 80 default;
server_name www.bac.com;
index index.html index.htm index.php;
root /data/httpd/csm.shopex.cn;
location ~ .*\.php?$
{
include fastcgi.conf;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
expires 30d;
location ~ .*\.(js|css)?$
expires 1h;
access_log /usr/local/nginx/logs/csm.log access;
}
3、說明
$remote_addr 與$http_x_forwarded_for 用以記錄用戶端的ip位址;
$remote_user :用來記錄用戶端使用者名稱;
$time_local : 用來記錄通路時間與時區;
$request : 用來記錄請求的url與http協定;
$status : 用來記錄請求狀态;成功是200,
$body_bytes_s ent :記錄發送給用戶端檔案主體内容大小;
$http_referer :用來記錄從那個頁面連結通路過來的;
$http_user_agent :記錄客戶毒啊浏覽器的相關資訊;
<a href="http://www.055680.com/" target="_blank">城市物語</a>
本文轉自yuangang_love 51CTO部落格,原文連結:http://blog.51cto.com/linux008/595749,如需轉載請自行聯系原作者