alibabamama 发表于 2018-11-26 08:18:29

在apache的日志中记录访问者的IP信息

关于apache 的 access.log 日志中记录访问的 client IP 解决方法入如下:  apache的httpd.conf中要修改LogFormt:
  LogFormat "%{X-Forwarded-For}i %h %l %u %o %t \"%r\" %>s \"%{Referer}i\" \"%{User-Agent}i\"" combined
  要把默认的%h改成%{X-Forwarded-For}i,
  得到的日志如下:
  10.10.10.37 192.168.1.89 - - - "GET /index.htm HTTP/1.1" 304 "-" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)"
  或这种格式:
  10.10.10.37 - - "GET /index.htm HTTP/1.1" 200 107 "-" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)"
  192.168.1.89 - - - "GET /index.htm HTTP/1.1" 200 "-" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)"

页: [1]
查看完整版本: 在apache的日志中记录访问者的IP信息