Hosting multiple domains on single webapp folder in tomcat : <p>Possible duplicate of <a href="https://stackoverflow.com/questions/16763938/multiple-domains-to-single-webapp-in-tomcat">this</a> but answer is not accepted.</p>

<p>I have 2 scenarios</p>

<ol>
<li>We are building a CRM and we will be having multiple clients using same product. Lets take a example, <code>subdomain1.maindomain1.com</code> and <code>anysubmain.anothermaindomain.com</code> should be pointed to same webapp folder. And depending on domain, we will select database dynamically but codebase will remain same. <strong><em>Point to note here : Whole codebase remains same</em></strong>.</li>
<li>We are building series of website for a client where part of the codebase will remain same for all but depending on subdomain we will load the default servlet file. Lets take example, <code>manage.domain.com</code> <code>crm.domain.com</code> <code>equote.domain.com</code> should be pointing to same webapp folder. And depending on domain we will load default servlet file. <strong><em>Point to note here : Part of codebase will remain same for all domains. Ex. core architect files</em></strong>.</li>
</ol>

<p>What solutions other have suggested</p>

<ol>
<li><a href="https://stackoverflow.com/a/16764089/1056620">Deploy copy of same war file 2 time, Softlink, Create 2 contexts that point to the same file, Use alias</a>. Last one can be good option but no idea how we can use this for different subdomains / domains.</li>
<li><a href="https://stackoverflow.com/a/49726750/1056620">This can be one of the solution but not sure whether it will work on same port or different port </a></li>
<li>There are many articles over internet which shows how we can deploy multiple webapps on multiple domain on single tomcat server but not the way i need.</li>
</ol>

<p>Note: I can create 2 AWS EC2 instances for above 2 scenarios. It means that I am not expecting one solution to above 2 problems.</p>
