Multiple Domains with Public IP

Setting Up Multiple Domains with Public IP

Multiple custom domains can be routed to different applications hosted inside one Tomcat environment by attaching a public IP, deploying each application into its own context, and configuring a separate Tomcat Host entry for every domain.
Better Usability Different domains can provide separate entry points, campaigns, designs, or user experiences.
Reduced Infrastructure Cost Several applications and domains can share one Tomcat environment instead of using a separate server for each domain.

Requirements

  • Registered domain names or administrative access to their DNS settings.
  • A Tomcat environment with a public IPv4 address.
  • One deployable WAR package for each application.
  • A unique application context for every domain.

Create the Environment

1Open the platform dashboard

Sign in to your PaaS account and click Create environment or New Environment.

Create environment button
Start environment creation from the platform dashboard.

2Select Tomcat and enable Public IPv4

In the topology wizard, choose Tomcat as the application server, enable Public IPv4, define the resource limits, enter an environment name such as multibinding, and create the environment.

Tomcat environment wizard with Public IPv4
Create a Tomcat environment with a public IPv4 address.

After provisioning is complete, the environment appears in the dashboard.

Tomcat environment for multiple domains
The environment is ready for domain binding and application deployment.

Bind Domains to the Public IP

Expand the Tomcat node details and copy its public IP address. Configure the DNS records for every domain so that they point to this address.

Tomcat server public IP
Use the server’s public IP for the DNS records of all required domains.
The exact DNS procedure depends on the registrar or hosting company managing the domain. DNS propagation may take some time.

Deploy Applications to Separate Contexts

3Upload the WAR packages

Open Deployment Manager and upload the application WAR files.

4Deploy each application separately

Deploy every package to the same Tomcat environment, but assign a different context to each application, such as firstdomain, seconddomain, and thirddomain.

Applications deployed to different contexts
Each WAR package must use a separate deployment context.

Configure Multiple Tomcat Hosts

5Open the Tomcat configuration

Click Config for the Tomcat application-server layer.

Tomcat Config button
Open the Tomcat configuration-file manager.

6Edit server.xml

Open server.xml in the Tomcat server directory and add one <Host> block for each custom domain.

<Host name="firstdomain.com"
      appBase="webapps/firstdomain">
    <Alias>firstdomain.com</Alias>
    <Context path="" docBase="."/>
</Host>

<Host name="seconddomain.com"
      appBase="webapps/seconddomain">
    <Alias>seconddomain.com</Alias>
    <Context path="" docBase="."/>
</Host>

<Host name="thirddomain.com"
      appBase="webapps/thirddomain">
    <Alias>thirddomain.com</Alias>
    <Context path="" docBase="."/>
</Host>
name and Alias Enter the custom domain name.
appBase Enter the folder corresponding to the application context under webapps.
Multiple Host entries in Tomcat server.xml
Add one Host entry for each domain and application context.
Configuration safety: Back up server.xml before editing it. Invalid XML can prevent Tomcat from starting.

Restart and Verify

7Save and restart Tomcat

Save the updated server.xml file and restart the Tomcat node.

Open each custom domain in a browser. Every domain should load the application linked to its matching Tomcat context.

First custom domain
The first domain opens its assigned application.
Second custom domain
The second domain opens a separate application context.
Third custom domain
The third domain is routed to its configured application.

Application Redeployment Note

Before redeployment: When redeploying an application to a Tomcat instance with an existing custom server.xml configuration, temporarily comment out the related <Host> block. After redeployment completes, uncomment the block and restart Tomcat if required.

What’s next?