[Yanel-usage] Virtual Host configuration with Tomcat

Michael Wechner michael.wechner at wyona.com
Tue Sep 27 15:23:15 CEST 2011


Am 25.09.08 14:49, schrieb Michael Wechner:
> Hi
>
> So far I have always used Apache httpd and mod_proxy to do virtual 
> hosts configuration, but I just learned that one
> can also do this with Tomcat rather easily in three steps
>
> 1) Change TOMCAT/conf/server.xml file, for example:
>
> <Host name="localhost" appBase="webapps"
>       unpackWARs="true" autoDeploy="true"
>       xmlValidation="false" xmlNamespaceAware="false">
> </Host>
>
> <Host name="www.yulup.org" appBase="webapps_yulup"
>       unpackWARs="true" autoDeploy="true"
>       xmlValidation="false" xmlNamespaceAware="false">
> <Alias>www.yulup.com</Alias>
> </Host>
>
> 2) Add an actual appBase, for example:
>
>    TOMCAT/webapps_yulup
>
> 3) Add a webapp config dir, for example:
>
>   TOMCAT/conf/Catalina/www.yulup.org/ROOT.xml

please note that in the case of the context element

http://oreilly.com/java/archive/tomcat-tips.html
http://tomcat.apache.org/tomcat-5.5-doc/config/host.html
http://tomcat.apache.org/tomcat-5.5-doc/config/context.html

one can set an attribute called "path", but this is used to match 
incoming requests onto a context (which is referencing the webapp with 
the docBase attribute) and can NOT be used to map onto a yanel (sub-)realm.

In order to map onto a yanel (sub-)realm one has to use something like 
Apache httpd in front with appropriate
virtual host entries, e.g.

     ProxyPass / ajp://localhost:8080/foobar/
     ProxyPassReverse / ajp://localhost:8080/foobar/

which means in such a case you should NOT set a path attribute for the 
context element, but let yanel do the work, e.g.


<realm id="foobar" mount-point="/foobar/">
<config src="/home/foobar/my-realm/"/>
<reverse-proxy>
<host-name>www.foo.bar</host-name>
<prefix>/foobar</prefix>
</reverse-proxy>
</realm>

HTH

Michael

>
> and this also works in combination with mod_jk, because mod_jk seems 
> to propagte the requested domain name,
> and hence one can still use Apache httpd in front of Tomcat ;-)
>
> Cheers
>
> Michael
>
>     _______________________________________________
> Yanel-usage mailing list
> Yanel-usage at wyona.com
> http://lists.wyona.org/cgi-bin/mailman/listinfo/yanel-usage



More information about the Yanel-usage mailing list