Ruk-Com PaaS Documentation

Build, deploy and operate applications on the platform.

RUK-COM PAAS / APPLICATION SETTINGS

Multiple Domains for Tomcat

This guide is maintained for Ruk-Com PaaS. Screens and options may vary by platform version and account permissions.

Confirm the environment, region and account permissions, and back up current settings before changing a production system.

Set up multiple domain names on the Tomcat server in order to increase the usability, efficiency and scalability of your application, as well as save your costs without having to configure separate instances. For this, make some minor adjustments within Tomcat configuration files as described below.

  1. Log into the platform dashboard and click the New Environment button:

Image 40: PaaS main buttons 2. In the Environment Topology dialog, pick your application server (e.g., Tomcat 9), and type your environment name, for example, multibinding.

Image 41: topology wizard In a minute your environment will be successfully created.

Image 42: new Tomcat environment 3. You can buy and set up your own domain names instead of default ones by adding CNAME record or by setting A Records. Read more in the Custom External Domain Name Binding document.

  1. Go back to the platform dashboard, click the Settings button for your environment and bind your domains.

Image 43: environment settings button In our example, we’ll use tomcatfirst.tk for the first domain name, and tomcatsecond.tk for the second.

Image 44: bind custom domain 5. Now you need to deploy the projects.

  • Upload the application file to the Deployment Manager and press Deploy to button.

As an example, we use Hello World which is available in Deployment Manager by default.

Image 45: deploy application When the Deploy form appears choose your environment and assign the context (tomcatfirst, in our case). Then press Deploy button.

Image 46: deploy dialog * Upload the second application archive. We will use modified Hello World (the words “You did it!” are recolored in red) just to see the difference at the final steps.

Then deploy this application to the same environment but with different context, (e.g., tomcatsecond).

Image 47: deploying second app into environment When deployment is finished you have two applications deployed in your environment.

Image 48: environment with two apps 6. Now click on Сonfig button for Tomcat and navigate to server.xml file (the /opt/tomcat/conf directory).

Image 49: server.xml config file Add Host tags for each domain you want to bind:

xml Copy

<Host name="external.domain.tld" appBase="webapps/context_name" autoDeploy="true">
    <Alias>external.domain.tld</Alias>
    <Context path="" docBase="${catalina.base}/webapps/context_name"/>
</Host>

In our sample, we add the following code to server.xml file:

xml Copy

<Host name="tomcatfirst.tk" appBase="webapps/tomcatfirst" autoDeploy="true">
<Alias>tomcatfirst.tk</Alias>
<Context path="" docBase="${catalina.base}/webapps/tomcatfirst"/>
</Host>
<Host name="tomcatsecond.tk" appBase="webapps/tomcatsecond" autoDeploy="true">
<Alias>tomcatsecond.tk</Alias>
<Context path="" docBase="${catalina.base}/webapps/tomcatsecond"/>
</Host>

Image 50: configuring tomcat server 7. Save the changes and restart Tomcat.

Image 51: restart nodes button 8. Now you can check the results. Both your applications will be available through the specified domain names running on a single Tomcat server.

Image 52: first application with custom domainImage 53: second application with custom domain

Note: If you want to redeploy an application to the Tomcat instance with already configured server.xml, you need to comment < Host > block before redeploying and uncomment it afterwards.