Hi,

Thank you André for your clear explanation below.  I am aware already of
how the directory structure relates to URL formation and, thanks to you
and others, now understand the significance of <Host> elements within an
<Engine>.  And I see how the default host is configured.

It doesn't, though, quite answer my particular issue.  Apache Roller is a
weblog server, that handles multiple domains - e.g. blog.host1.com,
blog.host2, etc.  But, at the present time, to correctly form URLs within
the HTML it serves up, Roller must run as the default Tomcat application. 
Therefore, it is installed at /usr/local/tomcat/webapps/ROOT.

Here is what is happening:

1) HTTP request comes into my webserver with the URL:
http://blog.christopher.net.nz
2) Apache HTTP server receives this on port #80
3) mod_rewrite appends /christopher to the end of the URL of the request
header (Roller recognises this as the "handle", so it serves up the
correct blog page)
4) mod_proxy forwards request on to Tomcat's AJP port #8009
5) Tomcat receives this but, with the current configuration, invokes the
application at webapps/christopher.  Instead, I would like it to invoke
the default (Roller) application at webapps/ROOT.

Interestingly, if I browse to another domain hosted by Roller -
http://blog.bread.co.nz(/bread) - as I don't happen to have an application
at webapps/bread, Tomcat handles this fine.  The default application
(Roller) serves up the weblog for handle="bread".

Thanks & regards,

Chris.


> Christopher Dodunski wrote:
>> Hi,
>>
>> Thanks, but I'm not quite clear on how to direct Tomcat to call the ROOT
>> application for a given domain.  I added the bottom <Host> element to
>> server.xml, but it doesn't appear to work correctly.
>>
>> <Engine name="Catalina" defaultHost="localhost">
>>   <Host name="localhost"  appBase="webapps" unpackWARs="true"
>> autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false">
>>   </Host>
>>   <Host name="blog.christopher.net.nz" appBase="webapps/ROOT" />
>> </Engine>
>>
>> Previously, the URL http://blog.christopher.net.nz/christopher called up
>> webapps/christopher, when it should instead have been handled by Apache
>> Roller running with ROOT context.  Now that I have added the above
>> directive, Tomcat reports "The requested resource () is not available".
>>
>> The URL http://blog.bread.co.nz/bread is handled by Roller, as intended,
>> because there is no competing application at webapps/bread.
>>
> It is difficult to respond clearly to your questions, because they seem to
> be based on the
> wrong premises, and/or they are confusing as to what you are really trying
> to achieve.
> We also have no idea what the ROLLER application is, and how itself needs
> to be set up.
>
> But here are some basic principles :
>
> 1) this line :
>   <Engine name="Catalina" defaultHost="localhost">
> indicates which one of your <Host> below, is the default host.
> The default Host is the one which will handle any request which arrives at
> this server,
> and for which the hostname does not match one of the other <Host> tags.
> In you case thus, this
> <Host name="localhost"..
> is the default Host.
>
> 2) each separate Host should have a separate "appBase", not overlapping
> the others.
> So, having one Host with appBase="webapps", and another Host with
> appBase="webapps/xxxx"
> is a nono, you should not do that.
> Create another directory, for example (tomcat_dir)/webapps-blog, and use
> that one to put
> the applications related to your host blog.christopher.net.nz, like
> <Host name="blog.christopher.net.nz" appBase="webapps-blog" />
> (You can also define this directory totally outside the hierarchy of the
> main Tomcat, like
> at /var/websites/blog.christopher.net.nz, and then use
> <Host name="blog.christopher.net.nz"
> appBase="/var/websites/blog.christopher.net.nz" />
>
> 3) within each "applications base" (appBase), each application will
> correspond to a
> directory, with the same name as the application.
> So for example, under (tomcat_dir)/webapps/, you can have one application
> called "app1"
> and another called "app2", for a structure like this
>    tomcat_dir/webapps/
>                      app1/
>                      app2/
>
> 4) To call any of these applications, you will use a URL like :
>     http://host-name/app1
>     http://host-name/app2
>     etc..
>
> 5) the special name "ROOT" is reserved for the "default application"
> within a Host.
>     That is the application which users would get if they simply entered
>     http://host-name/
>
> So, to modify the structure given above so that there would be, in
> addition to app1 anbd
> app2, a default application, you would have :
>
>    a) a file structure like this :
>    tomcat_dir/webapps/
>                      ROOT/
>                      app1/
>                      app2/
> and users could ask for :
>
>     http://host-name/      (to get the default application)
>     http://host-name/app1  (to get the app1 application)
>     http://host-name/app2  (to get the app2 application)
>
> Does this clarify things ?


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

Reply via email to