当Apache和nginx等Web服务器前端有负载均衡设备或者CACHE SERVER等情况下,APACHE日志中无法正确获取CLIENT的源IP,无法统计访问量,这个时候就要做一些设置上的更改,这里举例为squid3+apache2.2环境
一、修改Squid配置文件
vi ./squid.conf
emulate_httpd_log on
logformat combined %>a %ui %un [%tl] "%rm %ru HTTP/%rv" %Hs %h" "%{User-Agent}>h" %Ss:%Sh 改为
logformat combined %{X-Forwarded-For}i %>a %ui %un [%tl] "%rm %ru HTTP/%rv" %Hs %h" "%{User-Agent}>h" %Ss:%Sh
access_log /home/web/squid3/var/logs/access.log combined
二、修改Apache配置文件
vi ./httpd .conf
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
# squid proxy
LogFormat "%{X-Forwarded-For}i %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %b" common
但是Squid会报错,说语法错误,其实只要修改Apache配置文件就可以了
阅读(1678) | 评论(1) | 转发(0) |