tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From André Warnier ...@ice-sa.com>
Subject Re: How to configure different default webapp in function of requested hostname on one tomcat server
Date Thu, 26 Aug 2010 12:14:01 GMT


arnaud icard wrote:
> httpd is stopped.
> 
> Here is what I have done in the /opt/tomcat/conf/server.xml :
> 
>    /<Engine name="Catalina" defaultHost="tomcat00c">
>    ...
>    <Host name="tomcat00c"  appBase="webapps"
>                 unpackWARs="true" autoDeploy="true"
>                 xmlValidation="false" xmlNamespaceAware="false">
> 
>    <Valve className="org.apache.catalina.valves.AccessLogValve"
>    directory="/var/log/tomcat/hosts/"
>                    prefix="tomcat00c_access_log." suffix=".log"
>    pattern="common" resolveHosts="false"/>
>    </Host>
> 
>    <Host name="cas"  appBase="/home/tomcat/hosts/cas/webapps"
>                 unpackWARs="true" autoDeploy="true"
>                 xmlValidation="false" xmlNamespaceAware="false">
> 
>    <Valve className="org.apache.catalina.valves.AccessLogValve"
>    directory="/var/log/tomcat/hosts/"
>                    prefix="cas_access_log." suffix=".log"
>    pattern="common" resolveHosts="false"/>
>    </Host>
> 
>    <Host name="appli1"  appBase="/home/tomcat/hosts///appli1///webapps"
>                 unpackWARs="true" autoDeploy="true"
>                 xmlValidation="false" xmlNamespaceAware="false">
> 
>    <Valve className="org.apache.catalina.valves.AccessLogValve"
>    directory="/var/log/tomcat/hosts/"
>                    prefix="//appli1//_access_log." suffix=".log"
>    pattern="common" resolveHosts="false"/>
>    </Host>
>    </Engine>/
> 
> When connecting to appli1.test.fr, I am redirected to the default ROOT 
> content (which means to the tomcat00c host).
> 
> I am a little lost now in this tomcat jungle. No black smoke so far 
> hopefully :)
> 

It is very simple, really :

1) The defaultHost (as named in the Engine tag) is the one which will serve the request 
(any request), when Tomcat is unable to match the request's hostname *exactly* with one of

the <Host> tags' name attribute.
In your case, you have a Host with name="appli1", but the request says "appli1.test.fr". 
That does not match ("appli1" != "appl1.test.fr"). So Tomcat defaults to the defaultHost 
"tomcat00c".

(Under Apache httpd, the default VirtualHost is the first one named, from top to bottom.
In Tomcat, the order does not matter, since you explicitly say which one is the 
defaultHost, in the Engine tag.)

2) something similar would happen with the application's name :
A request for "http://appli1.test.fr/appli1" would normally be mapped to the Context 
"/appli1" in the Host named "appli11.test.fr".  But instead (see (1)), it gets mapped to 
the defaultHost.  And this defaultHost does not have an application named "appli1", so the

request gets mapped to the default application (ROOT) in the defaultHost (tomcat00c), 
inside which Tomcat will be looking for a subdirectory 
(catalina_base)/webapps/ROOT/appli1, and probably not find it.

3) you have far too many repeated "//" in your Host appli1.  I am quite sure that the 
prefix for the access log will not work as shown.



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message