Ideas2IT rewards key players with 1/3rd of the Company in New Initiative.  Read More >
Back to Blogs

Multiple Subdomains in Apache / Tomcat with mod_jk

Our goto server for Enterprise J2EE apps is Tomcat. Frequently we come across the requirement of deploying multiple web applications on the same Tomcat and mapping different subdomains to each web app.For example,<pre> to an app deployed in webapps/ to an app deployed in webapps/erp</pre>We usually do this with virtual host facility available in Tomcat.<pre><Host name="crm" appBase="webapps"><Context path="" docBase="crm/"/></Host><Host name="erp" appBase="webapps"><Context path="" docBase="erp/"/></Host></pre>Now if you setup your DNS with the 2 subdomain entries, the sub-domains will be forwarded to the appropriate web apps by Tomcat.Apache mod_jk:We usually deploy Tomcat in a cluster in production using Apache and mod_jk. We need to do the following for that:<pre><VirtualHost> ServerName JkMount / tomcat JkMount /* tomcat</VirtualHost><VirtualHost> ServerName JkMount / tomcat JkMount /* tomcat</VirtualHost></pre>Ofcourse this is http. For https we do our usual SSL steps. Your will look something like this:<pre>worker.list= tomcat, = 1worker.tomcat.balance_workers=tomcat1,tomcat2worker.status.type=status</pre>Note: If after all this configuration, all sub domain still get redirected to the default web app, make the following change,<pre><Host name="" appBase="webapps"><Context path="" docBase="crm/"/></Host><Host name="" appBase="webapps"><Context path="" docBase="erp/"/></Host></pre>This is because mod_jk will forward the domain name as is.

Are you looking to build a great product or service? Do you foresee technical challenges? If you answered yes to the above questions, then you must talk to us. We are a world-class custom .NET development company. We take up projects that are in our area of expertise. We know what we are good at and more importantly what we are not. We carefully choose projects where we strongly believe that we can add value. And not just in engineering but also in terms of how well we understand the domain. Book a free consultation with us today. Let’s work together.

Ideas2IT Team

Connect with Us

We'd love to brainstorm your priority tech initiatives and contribute to the best outcomes.