Published on Mar 1 2023 in Control Panels Java Tomcat

Control Web Panel aka CWP users can use Java/Tomcat in many ways (not only via the built-inb CWP Tomcat engine that runs under a dedicated user). Each user can have their own application server and JVM.

This article provides a guide on setting up multiple domains with Java support in the Control Web Panel (CWP). Users can employ Java/Tomcat in various ways, allowing each user to have their own application server. The article explores three likely scenarios for multiple domains and Java applications, detailing the steps for implementation. Scenario ‘a’ is particularly outlined, illustrating how to configure one account with one or more domains and a Tomcat server. The guide covers domain pointing, SSL certificate renewal, web server configuration, Tomcat webapps directory creation, server.xml modifications, and proxy setup. Scenario ‘b’ is also introduced for users requiring separate web applications and restricted user access, with detailed steps for each user setup.

For multiple domains and multiple Java applications there are 3 most likely scenarios:

  1. One account with one or more domains and one Tomcat

  2. Multiple accounts where each of them is hosting one or more domains and a Tomcat

  3. A mix of above

Scenario ‘a’: Setting up one account with multiple domains and a Tomcat server

We will use user tomcat and, as the example domains.

  1. Begin by pointing the domains ( and to your server IP using the domain registrar’s DNS service or Cloudflare DNS service.

  2. Utilize CWP to renew SSL certificates for the domains under Webserver Settings > SSL Certificates > AutoSSL [Free].

  3. Using CWP - Webserver Settings > Webserver Conf Editor > /usr/local/apache/conf.d/vhosts/ > /usr/local/apache/conf.d/vhosts/ uncomment # IncludeOptional ... line. Repeat the same for /usr/local/apache/conf.d/vhosts/ Repeat these 2 edits for additional domains if necessary.

  4. Create tomcat webapps directories for the 2 domains i.e.


You can do it using SSH (as user tomcat) and mkdir command or using Midnight Commander file manager (mc command) in SSH or web-based terminal. These directories must be owned by tomcat user. If you created them as root do not forget to run su - tomcat -c 'chown -R tomcat: $CATALINA_HOME'.

Upload your web applications renamed to ROOT.war to respective directories.

  1. Also as user tomcat, edit /home/tomcat/apache-tomcat-9.0.63/conf/server.xml (you can use F4 in Midnight Commander or an editor of your choice) and add 2 Host entries, e.g.:
<Host name="" autoDeploy="true" appBase="webapps_domain1" unpackWARs="true">
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
    prefix="domain1.com_access_log." suffix=".txt"
    pattern="%h %l %u %t &quot;%r&quot; %s %b" resolveHosts="false"/>

For the snippet is the same, just update domain name in 4 places.

  1. Restart Tomcat (as user tomcat) with sudo systemctl restart java-tomcat or use whatever start/stop mechanism is used on your server (including vanilla scripts).

  2. Verify tomcat log /home/tomcat/apache-tomcat-9.0.63/logs/catalina.out. It can take several seconds for the ‘Server started’ message to appear the the log.

  3. Set up proxy that will work for both HTTP and HTTPS connections and will allow you to skip Tomcat port number from URL:

mkdir -p /usr/local/apache/conf/userdata/tomcat/
cat > /usr/local/apache/conf/userdata/tomcat/<<EOF
ProxyPreserveHost On
ProxyPass / ajp:// retry=5
ProxyPassReverse / ajp://

Finally restart webserver (frontend) with systemctl restart httpd.

Scenario ‘b’: Setting up multiple accounts, each hosting one or more domains and a Tomcat server

If you need to separate web applications so that each user has only access to his application use this scenario. It will also prevent misbehaving application of domain1 to impact functioning of domain2 application. Follow above steps for a single user say ‘tomcat1’ and his domain or domains. Then do the same for next user say ‘tomcat2’. Do not forget to update ports in Tomcat’s server.xml and proxy.conf so that tomcat2 ports do not conflict with the ones of tomcat1.