Apache logs - what's the difference between% a and% h?

% a is “Remote IP Address” and% h is “Remote Host,” but when I test it, both print the same IP addresses. Who cares?

log output for log format "% a% h:

192.168.1.2 192.168.1.2 192.168.1.2 192.168.1.2 192.168.1.2 192.168.1.2 
+4
source share
2 answers

The remote host value is trying to do a DNS lookup on the IP address to give you the host name if the resolveHosts attribute is set to True. If not, the remote host simply returns the remote IP address.

+4
source

% h is the host name, and% a is the IP address. % h will only show the host name if apache does the name resolution. This can significantly slow down your server and is generally not recommended.

The following% h description is taken directly from the Apache documentation : -

This is the IP address of the client (remote host) that made the request to the server. If HostnameLookups is set to On, then the server will try to determine the host name and register it instead of the IP address. However, this configuration is not recommended, as it can significantly slow down the server. Instead, it is best to use a post-log processor such as logresolve to determine host names. The IP address provided here is not necessarily the address of the machine on which the user is located. If a proxy server exists between the user and the server, this address will be the proxy address, not the source machine.

+1
source

Source: https://habr.com/ru/post/1285788/


All Articles