Because load balancing forwards the client's request to the Web server, the Web service often logs a load-balanced IP, which can now be configured to let Apache record the real client IP
Grammar
#LogFormat "\"%{x-forwarded-for}i\ "%l%t \"%r\ "%>s%b \"%{referer}i\ "\"%{user-agent}i\ "" combined
common logs and records for client IPApacheLog Comparison
#LogFormat "%h%l%u%t \"%r\ "%>s%b \"%{referer}i\ "\"%{user-agent}i\ "" combined
#LogFormat "\"%{x-forwarded-for}i\ "%l%t \"%r\ "%>s%b\"%{referer}i\ "\"%{user-agent}i\ "" combined
number of client accesses in the statistics log
Cut-d ""-f1 Www.sr1.com_access_log | Sort |uniq-c|sort-rn-k1
Results:
4799 192.168.254.251
1335 192.168.254.250
2 192.168.254.191
ApacheDo not log health check logs
Because load-balanced health checks cause Apache to write large amounts of access logs, which makes it impossible to count traffic, use the following method to let Apache no longer record the load-balanced health Check log
Configuration (Checkstatus.html):
Setenvifrequest_uri "^/checkstatus.html" DontLog
Errorlog "Logs/error_log"
LogLevel warn
Customlog "Logs/access_log" combined Env=!dontlog
The virtual host does not record the Health check log (Checkstatus.html):
<VirtualHost*:80>
DocumentRoot "/usr/local/httpd-2.2.9/htdocs/sr1/"
ServerName www.sr1.com
Serveralias www.sr1.com
Setenvif Request_uri "^/checkstatus.html" DontLog
Errorlog "Logs/www.sr1.com_error_log"
Customlog "Logs/www.sr1.com_access_log" Haproxy env=!dontlog
</VirtualHost>
This article is from the "Study-everyday" blog, make sure to keep this source http://studys.blog.51cto.com/9736817/1591441
Apache about recording real client IP and not logging health check logs