REMOTE_HOST turned off?


Apache no longer seems to return REMOTE_HOST variable lately. Has this setting been turned off permanently? I have a couple of scripts that rely on this variable to get the hostname…


From the Apache documentation:

"HostnameLookups and other DNS considerations

Prior to Apache 1.3, HostnameLookups defaulted to On. This adds latency to every request because it requires a DNS lookup to complete before the request is finished. In Apache 1.3 this setting defaults to Off. If you need to have addresses in your log files resolved to hostnames, use the logresolve program that comes with Apache, or one of the numerous log reporting packages which are available.

It is recommended that you do this sort of postprocessing of your log files on some machine other than the production web server machine, in order that this activity not adversely affect server performance.

If you use any Allow from domain or Deny from domain directives (i.e., using a hostname, or a domain name, rather than an IP address) then you will pay for a double reverse DNS lookup (a reverse, followed by a forward to make sure that the reverse is not being spoofed). For best performance, therefore, use IP addresses, rather than names, when using these directives, if possible.

Note that it’s possible to scope the directives, such as within a <Location /server-status> section. In this case the DNS lookups are only performed on requests matching the criteria. Here’s an example which disables lookups except for .html and .cgi files:

HostnameLookups off
<Files ~ “.(html|cgi)$”>
HostnameLookups on

But even still, if you just need DNS names in some CGIs you could consider doing the gethostbyname call in the specific CGIs that need it."

Hope this helps.

:cool: Perl / MySQL / HTML+CSS