通路日志記錄使用者的每一個請求
vi conf/extra/httpd-vhosts.conf
看操作的虛拟機下面的對應日志
ErrorLog "logs/111.com-error_log"
CustomLog "logs/111.com-access_log" common
cat logs/111.com-access_log
HEAD狀态都是curl出來的。
Get狀态就是不加-I
vim /usr/local/apache2.4/conf/httpd.conf //搜尋LogFormat
提供兩種日志格式,而預設使用的是common。
Referer比如我登入百度之後,點選視訊,伺服器就會記錄位址欄現在的網址,還會記錄一個資訊就是Referer,浏覽器上一次的網址是什麼,就是baidu.com
%h %l %u %t %r\"% %>s %b %{Referer}i\ %{UserAgent}i
來源ip 使用者 使用者名密碼 時間 行為,網址 狀态碼 大小 上一個網址 使用者代理。浏覽器或者curl
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %b" common
%h %l %u %t %r\"% %>s %b
來源ip 使用者 使用者名密碼 時間 行為,網址 狀态碼 大小
把虛拟主機配置檔案改成如下:
<VirtualHost *:80>
DocumentRoot "/data/wwwroot/www.123.com"
ServerName www.123.com
ServerAlias 123.com
CustomLog "logs/123.com-access_log" combined
</VirtualHost>
重新加載配置檔案 -t,graceful
網站通路和curl
curl -x127.0.0.1:80 -I 123.com
tail /usr/local/apache2.4/logs/123.com-access_log
Curl的Referer是空的。因為是curl不存在上一次網址是什麼這一說
本文轉自 蝦米的春天 51CTO部落格,原文連結:http://blog.51cto.com/lsxme/2052683,如需轉載請自行聯系原作者