标签类目:combined

Apache 在代理后显示正确的用户IP

分类:Apacheapache日志中默认有%h来指定来访客户端你的ip地址,但是如果客户端使用了代理上网则%h获得的ip地址会不准。可以设定 X-Forwarded-For 参数来获取客户端真实的ip地址

对于使用了反向代理的客户端,跟踪真实的ip地址

  1. %{X-Forwarded-For}i
  2.  
  3. LogFormat "%{X-Forwarder-For}i %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" linuxanyproxy
  4. LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
  5.  
  6. SetEnvIf X-Forwarder-For "^.*\..*\..*\..*" is-forwarder
  7.  
  8. CustomLog logs/access_log combined env=!is-forwarder
  9. CustomLog logs/access_log linuxanyproxy env=is-forwarder

继续阅读 »

Apache Logs: how long does it take to serve a request?

分类:ApacheApache is one complex piece of software, that contains many features most people are normally not using. You can do so many things with apache outside of the default configurations, and I am not going to discuss today about an external module, but about the plain old mod_log_config.

Normally most people will use for apache logging the combined LogFormat, and will not even think there will be other possible additions to that. This normally looks like:

LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined

and it contains most of the information we would like to see in the logs. Still there are many other information we can include here… just see below for the full list.

继续阅读 »


返回顶部