文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>squid3+apache2.2 记录客户端IP 关于X-Forwarded-For

squid3+apache2.2 记录客户端IP 关于X-Forwarded-For

时间:2010-10-18  来源:badb0y

当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 %<st "%{Referer}>h" "%{User-Agent}>h" %Ss:%Sh 改为
  logformat combined %{X-Forwarded-For}i %>a %ui %un [%tl] "%rm %ru HTTP/%rv" %Hs %<st "%{Referer}>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配置文件就可以了
相关阅读 更多 +
排行榜 更多 +
辰域智控app

辰域智控app

系统工具 下载
网医联盟app

网医联盟app

运动健身 下载
汇丰汇选App

汇丰汇选App

金融理财 下载