Pid wrote:
On 26/08/2010 13:40, André Warnier wrote:
arnaud icard wrote:
...
Yes this is where I made a mistake.
The parameters "name" and "defaultHost" must be the FULL name (i.e.
hostname.domain)
No. I mean no, it is not exactly that.
For the defaultHost, it does not matter very much, because it is the
default and anything that does not match exactly will end up there anyway.
But for the others, as far as I know, the point is that the Host name
attribute *must match the Host: header in the HTTP request, exactly*.
If requests can come in with a Host: header being just "appli1", then
you need to have, in the corresponding Host tag,
- either the name attribute = "appli1"
- or an <Alias>appli1</Alias> tag inside the <Host> section.
For example:
<Host name="appli1.test.fr">
<Alias>appli1</Alias>
...
</Host>
This reverse must be valid:
<Host name="appli1">
<Alias>appli1.test.fr</Alias>
...
</Host>
or the following would not work:
<Host name="appli1.test.fr">
<Alias>appli1.test.de</Alias>
...
</Host>
Pid, I don't get what you mean above.
Example :
To put DNS aside for a moment, suppose I have this in my local hosts file (which is
consulted by the local resolver before DNS gets involved) :
212.85.38.176 mira mira.wissensbank.com
(and, at this IP address, is a host with a Tomcat server listening on port 80)
So, as far as my local workstation is concerned, both "mira" and "mira.wissensbank.com"
are "aliases" of eachother, in the sense that they both resolve to the same IP address.
A) Then, I start a browser and request :
http://mira/
- the browser calls the local resolver to resolve "mira" into an IP address
- the local resolver looks up "mira" in the local hosts file, finds it, and returns the IP
address 212.85.38.176
- the browser now establishes a TCP connection with IP address 212.85.38.176
- when the TCP connection is obtained, the browser sends the following request over that
TCP connection :
GET / HTTP/1.1
Host: mira
...
- the Tomcat at this IP address gets the "Host:" header's value ("mira"), and looks up to
find a <Host> in its configuration, which has either
- the Host attribute name="mira"
- or an <Alias>mira</Alias>
If it does not find such, the request is passed to the default Host
B) If instead, the request which I type in the browser's URL bar is
http://mira.wissensbank.com
then
- the browser calls the local resolver to resolve "mira.wissensbank.com" into
an IP address
- the local resolver looks up "mira.wissensbank.com" in the local hosts file, finds it,
and returns the IP address 212.85.38.176
- the browser now establishes a TCP connection with IP address 212.85.38.176
- when the TCP connection is obtained, the browser sends the following request over that
TCP connection :
GET / HTTP/1.1
Host: mira.wissensbank.com
...
- the Tomcat at this IP address gets the "Host:" header's value ("mira.wissensbank.com"),
and looks up to find a <Host> in its configuration, which has either
- the Host attribute name="mira.wissensbank.com"
- or an <Alias>mira.wissensbank.com</Alias>
and if it does not find such, the request will be passed to the defaultHost.
All the above remains true even if there is nothing in the local hosts file, and the above
translations to IP address are made via a DNS lookup.
So, let's say that this Tomcat only has the following (non-default) Host tag :
<Host name="mira.wissensbank.com">
</Host>
then any request addressed by my browser to
http://mira
will end up being served by the defaultHost.
As long as the browser /can/ resolve the hostname into an IP address, it will always make
the connection to that IP address and send the request over it.
But the content of the "Host:" header will be the hostname as indicated in the request
URL, as is, and not necessarily translated to its canonical form.
Whether Tomcat itself would attempt to do some kind of DNS lookup for a partial name, in
order to "canonicise" it, is besides the point really, because even if it would - which
would surprise me - there is no certainty that it would be able to translate "mira" into
"mira.wissensbank.com".
It is very frequent in intranets to have a mixture of links floating around, some
referring only to the hostname, some with the full FQDN. If you want Tomcat to respond
properly to both kinds of links, you must have both names referenced inside the Host
section, whether as the host "name", or as an Alias.
It does not matter which one of them you use for the Host attribute or the Alias, but they
must both be there, or some requests will end up with the defaultHost.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org