Reputation: 701
I am using tomcat 5.5 and I want to do the following:
If two web applications are deployed (let them be foo and bar) I want to be able to access them both with relative paths and by aliases.
localhost:8080/foo -> foo and foo.example.com -> foo
and respectively
localhost:8080/bar -> bar and bar.example.com -> bar
If I use different Hosts within the Engine and provide aliases -as the documentation dictates- then the aliased urls work fine, but not the relative ones. In order to have them both working properly I need an extra host "localhost" and declare the same contexts again. Here is my server.xml
<Engine name="Catalina" defaultHost="localhost">
<Host name="foo.example.com">
<Context docBase="webapps/foo" path="" workDir="work/Catalina/foo/_"/>
<Alias>foo.example.com</Alias>
</Host>
<Host name="bar.example.com">
<Context docBase="webapps/bar" path="" workDir="work/Catalina/bar/_"/>
<Alias>bar.example.com</Alias>
</Host>
<Host name="localhost" appBase="webapps" autoDeploy="false" >
<Context path="foo" workDir="work/Catalina/foo/_" />
<Context path="bar" workDir="work/Catalina/bar/_" />
</Host>
</Engine
Although it works this way, it seems that tomcat is loading each context twice. Is there any other way to achieve this?
Upvotes: 1
Views: 2441
Reputation: 31903
It indeed loads the applications twice because you configured it that way. You'd need an apache httpd instance in front of tomcat to do some url rewrite magic.
Upvotes: 1