tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From John Turner <>
Subject Re: JKMount, virtual hosts, and avoiding the webapp name
Date Wed, 03 Sep 2003 21:37:17 GMT
Mike Curwen wrote:

> So it's gonna be something like:
> The Apache Vhost:
> <VirtualHost>
>    JKMount /*.jsp tomcat1
>    JKMount /fooservlet tomcat1
>    DocumentRoot /home/webhome/atm/htdocs/
>    ServerName
>    ServerAlias
>    ErrorLog /var/log/atm/error_log
>    CustomLog /var/log/atm/access_log combined
> </VirtualHost>
> relates to the TC Host:
> <Host name="" debug="0" appBase="webapps" unpackWARs="true">
>  <Alias></Alias>
>  <Context path="" docBase="home/webhome/atm" debug="0"
> reloadable="true"/>
> </Host>

Yeah, but I typically make DocumentRoot = ROOT docBase.  So on my 
servers I have something like this:

<Host name="" debug="1" appBase="VIRTHOST" 
unpackWARs="true" autoDeploy="true">
     <Context path="" docBase="VIRTHOST" debug="0" reloadable="true">


<VirtualHost *>
     DocumentRoot /usr/local/jakarta-tomcat-4.1.27/VIRTHOST/VIRTHOST

     # Static files
     Alias / "/usr/local/jakarta-tomcat-4.1.27/VIRTHOST/VIRTHOST"

     <Directory "/usr/local/jakarta-tomcat-4.1.27/VIRTHOST/VIRTHOST">
         Options Indexes FollowSymLinks
         DirectoryIndex index.jsp

     # Deny direct access to WEB-INF and META-INF
     <Location "/WEB-INF/*">
         AllowOverride None
         deny from all
     <Location "/META-INF/*">
         AllowOverride None
         deny from all

     JkMount /* ajp13

Which makes the following dir structure possible:


Apache DocumentRoot, and TC root Context, path="", docBase="VIRTHOST":

other Context, path="/SOME_OTHER_APP", docBase="SOME_OTHER_APP":

Yes, #2 above is redundant with having the same dir name twice, but it 
makes sense to me.  You could just as easily change it to ROOT or 
something else, but in my case, with many virtual hosts, I found myself 
saying "ok, this is ROOT, but WHICH ROOT?".  Using the domain name as 
the actual name of the directory for the root web app gets rid of this 

For other Contexts, you just add additional Alias commands to httpd.conf 
to get Apache to recognize dirs on the same level as the DocRoot instead 
of sub-dirs.

> Is that correct?  In this case, I'm replacing /ATM and /BDG apps with to
> Hosts under TC, with the default Context set to be a separate instance
> of that 'common' app.

Pretty much, I would just watch the DocumentRoot and Alias in 
httpd.conf, they can play tricks on you if you have them pointing to 
directories one level above or below your Context's docBase.

> I'm wondering about this from
>   worker.list=tomcat1
> Will I need to define a new work for each new host in TC,or can I supply
> a comma separated list to the entry?

No, you only need one worker.  ".host" = "location of machine running 
Tomcat", it does not need to match any virtual host name.  I used to 
think it did, back in the day, but I have since seen the error of my 
ways and have come back to the straight and narrow.  A basic 4-line will work for many virtual hosts.  I have servers 
with 5, 8, and 22 virtual hosts, all using one worker per physical 
server with no problems.

> Thanks very much John. :)

Glad to help, if I am.  Have fun.


View raw message