Re: Apache web host name resolution question
From: David Efflandt (efflandt_at_xnet.com)
Date: Fri, 9 Jul 2004 18:06:08 +0000 (UTC)
On Fri, 09 Jul 2004 11:54:12 -0500, Ed Marsh <email@example.com> wrote:
> I have just setup Apache web server, PHP, MySQL and PostgreSQL on my
> Fedora Core II system. When writing some HTML pages which call remote
> PHP routines, I noticed a long delay before the branched call to the PHP
> routine completes. I snooped the network and noticed that the web
> server is trying to resolve my server's hostname by going to the
> external DNS server. After this fails it resubmits the request to Yahoo
> and a few other lookup servers - fails, and then comes right back to my
> home gateway router where it directs the call back to the IP address of
> my Linux Apache server (where it should have been originally). The
> delay is about 90+ seconds or so. I am trying to do some performance
> testing, so this is not acceptable.
> I thought that the Apache web server would follow the instructions of
> the /etc/nsswitch.conf file and check the local /etc/hosts file first to
> resolve the hostname before using DNS, but this is apparently not the
> case. I suspect that I am going to have to set up a local domain in my
> private network and a proxy server to keep intranet queries local.
> However, I am hoping that I am wrong and someone has a simplier solution.
It could be your browser (which one?) that is using DNS and search first
before /etc/hosts. Some have a built-in DNS cache, or attempt to search
for a name. I know when I used to netscape, it thought that
http://localhost/ was an incomplete FQDN and would attempt to search for
localhost, and come up with localhost.com (a registered domain), which of
course would not have the local resource I was looking for. That feature
(Smart Search?) can be diasbled.
I do not know how you construct those PHP URLs, but perhaps using
HTTP_HOST from env and/or changing UseCanonicalName to off in apache may
help, so your browser would use the name that worked (from Host header)
instead of the server's set or assumed ServerName. But since you say
"remote" PHP you may need to do something more if accessed from LAN
or internet (maybe SSI or other dynamic content).
-- David Efflandt - All spam ignored http://www.de-srv.com/