Apache日志 - %a和%h之间有什么区别?

时间:2022-06-04 03:09:38

%a is "Remote IP-address" and %h is "Remote host", but when I test it, both print out the same IP addres. What's the difference?

%a是“远程IP地址”,%h是“远程主机”,但是当我测试它时,两者都打印出相同的IP地址。有什么不同?

sample log output for log format "%a %h:

日志格式“%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

2 个解决方案

#1


The remote host value tries to perform a DNS lookup on the IP address to give you a hostname, if the resolveHosts attribute is set to True. If not, remote host just returns the remote IP address.

如果resolveHosts属性设置为True,则远程主机值会尝试对IP地址执行DNS查找以为您提供主机名。如果没有,远程主机只返回远程IP地址。

#2


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

%h是主机名,%a是IP地址。如果apache正在进行名称解析,%h将仅显示主机名。这可能会显着降低您的服务器速度,通常不建议这样做。

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

以下对%h的描述直接取自Apache文档: -

This is the IP address of the client (remote host) which made the request to the server. If HostnameLookups is set to On, then the server will try to determine the hostname and log it in place of the IP address. However, this configuration is not recommended since it can significantly slow the server. Instead, it is best to use a log post-processor such as logresolve to determine the hostnames. The IP address reported here is not necessarily the address of the machine at which the user is sitting. If a proxy server exists between the user and the server, this address will be the address of the proxy, rather than the originating machine.

这是向服务器发出请求的客户端(远程主机)的IP地址。如果HostnameLookups设置为On,则服务器将尝试确定主机名并将其记录以代替IP地址。但是,建议不要使用此配置,因为它会显着减慢服务器的速度。相反,最好使用日志后处理器(如logresolve)来确定主机名。此处报告的IP地址不一定是用户所在机器的地址。如果用户和服务器之间存在代理服务器,则该地址将是代理的地址,而不是原始机器的地址。

#1


The remote host value tries to perform a DNS lookup on the IP address to give you a hostname, if the resolveHosts attribute is set to True. If not, remote host just returns the remote IP address.

如果resolveHosts属性设置为True,则远程主机值会尝试对IP地址执行DNS查找以为您提供主机名。如果没有,远程主机只返回远程IP地址。

#2


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

%h是主机名,%a是IP地址。如果apache正在进行名称解析,%h将仅显示主机名。这可能会显着降低您的服务器速度,通常不建议这样做。

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

以下对%h的描述直接取自Apache文档: -

This is the IP address of the client (remote host) which made the request to the server. If HostnameLookups is set to On, then the server will try to determine the hostname and log it in place of the IP address. However, this configuration is not recommended since it can significantly slow the server. Instead, it is best to use a log post-processor such as logresolve to determine the hostnames. The IP address reported here is not necessarily the address of the machine at which the user is sitting. If a proxy server exists between the user and the server, this address will be the address of the proxy, rather than the originating machine.

这是向服务器发出请求的客户端(远程主机)的IP地址。如果HostnameLookups设置为On,则服务器将尝试确定主机名并将其记录以代替IP地址。但是,建议不要使用此配置,因为它会显着减慢服务器的速度。相反,最好使用日志后处理器(如logresolve)来确定主机名。此处报告的IP地址不一定是用户所在机器的地址。如果用户和服务器之间存在代理服务器,则该地址将是代理的地址,而不是原始机器的地址。