tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bill Winspur <>
Subject Re: Virtual Hosting Questions
Date Tue, 23 Nov 2004 14:41:24 GMT
Thanks for your feedback. My findings are interleaved below.

>>Question 1: Is this hosts-file approach feasible? Does tomcat care HOW
>>domain names
>>are mapped to IP addresses?
>It's more of a Java networking question that Tomcat question.  I'm not
>sure how java's InetAddress class likes hosts files: my guess is they're
The mapping of domain names to ip's is done (as usual) in the IP stack. 
Thus, using the /hosts /files on
tomcat client and server boxes works fine for development scenarios 
where you do not want to
expose you production domain names to the Internet via DNS. I originally 
asked the question
because the tomcat docs only mention DNS as the mapping agent, which 
seemed overly specific
to me, unless tomcat had some reason to insist on DNS, which is 
apparently not the case.

>>Question 2: Why is the host named localhost? From the documentation, I
> <>
> Localhost is just the default name. You can substitute any string in
> there, and have as many Hosts as you want inside the Engine, but the
> Host name must be unique within the Engine.

>>expected that only URL's of the form http://localhost:8080/... would be
>>handled by this virtual host, but it seems to handle any URL's that map
>>to the IP and port of the real host that tomcat serves.
>The name of the Host in server.xml is used primarily by Tomcat for
>internal management.  It doesn't have that much to do with the host name
>in the browser's URL.
I do not think /just the default name/ is correct. It seems that the 
name attribute value must be a name
 that the client and server IP stacks can map to an IP address for the 
configuration to work, which
does have to do with the host name in the browser's URL.

Also, the name 'localhost' seems to be 'magic' in that there is code 
triggered by the occurrence of that
particular name.  As others on the list have pointed out,  a value of 
'localhost' in the <Host name=...>
attribute is mapped to, so that the host can respond to requests 
from any domain.

If 'localhost' in this context is magic (I have not checked the source 
to confirm this), the documentation
should make this special usage of 'localhost' explicit. Alternatively, 
it would be much better to make the magic
host name 'any', 'all', or '*', which would avoid overloading 
'localhost' with a special-case meaning that
conflicts with its usual reference to the local IP environment.


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message