Apache about recording real client IP and not logging health check logs

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.