It's all about the answers!

Ask a question

Has anyone seen any problems with tomcat virtual hosting?


0
2
Paul Ellis (1.3k613) | asked Oct 31 '13, 12:08 p.m.
JAZZ DEVELOPER
edited Jan 20 '14, 6:44 a.m.

I want to use virtual hosting with Tomcat for allowing multiple hosts to be specified in the server.xml file for future use in an enterprise topology.  Has anyone seen any problems with this setup?

I am specifically referring to: http://tomcat.apache.org/tomcat-6.0-doc/virtual-hosting-howto.html

I intend to setup the following:

Public URI
https://rtc.intranet.com:9443/ccm
https://rrc.intranet.com:9443/rm
https://jts.intranet.com:9443/jts
https://rqm.intranet.com:9443/qm
 
 
DNS
rtc.intranet.com maps to 101.102.103.104
rrc.intranet.com maps to 101.102.103.105
jts.intranet.com maps to 101.102.103.106
rqm.intranet.com maps to 101.102.103.107

Accepted answer


permanent link
Alex Fitzpatrick (5583816) | answered Oct 31 '13, 12:20 p.m.
JAZZ DEVELOPER
edited Oct 31 '13, 12:28 p.m.
One known issue with Tomcat virtual hosts is that each host is configured to use a directory for it's "appBase" and all the servlets or war files in that directory will be deployed.

If the administrator is not careful they may re-use the same directory like the default "webapps" as the appBase for more than one virtual host and cause the same servlet to be activated more than once and addressable via multiple URIs. At best this results in extra CPU overhead, at worst this may lead to data corruption or loss since each running copy would also be sharing the same filesystem and database.

To make this work the administrator will need to create a directory for each virtual host and copy the servlets they want running on that host to that directory.

e.g.
       <Host name="rtc.intranet.com"  appBase="ccm-webapps" unpackWARs="true" autoDeploy="true"/>

       <Host name="rrc.intranet.com"  appBase="rrc-webapps" unpackWARs="true" autoDeploy="true"/>

       <Host name="jts.intranet.com"  appBase="jts-webapps" unpackWARs="true" autoDeploy="true"/>

       <Host name="rqm.intranet.com"  appBase="rqm-webapps" unpackWARs="true" autoDeploy="true"/>

And create matching directories

+---ccm-webapps
   +---ccm.war

+---rrc-webapps
   +---converter.war 
   +---rm.war

+---jts-webapps
   +---admin.war
   +---clmhelp.war
   +---jts.war

+---rqm-webapps
   +---qm.war

Paul Ellis selected this answer as the correct answer

Comments
Paul Ellis commented Nov 01 '13, 8:30 a.m.
JAZZ DEVELOPER

I also noted that there is a Maxthreads implication of this too.  https://jazz.net/forum/questions/91352/is-there-a-limit-to-the-maxthreads-value-for-tomcat-server highlights this issue in general, but as you'll have multiple connector port lines within one Tomcat instance, you would need to be careful with the MaxThreads setting.

Your answer


Register or to post your answer.


Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.