Web context per virtual host with a shared webroot

We have been attempting to figure out a way to create web context per tomcat virtual host that all share the same code base.

We are looking to have separate web contexts for each virtual host for a few reasons such as client specific logging, separate scheduled tasks, and each client’s site has their own datasource. So the only item that is shared is between clients is the code base.

OS: CentOS 7
Java Version: 11.0.6 (AdoptOpenJDK) 64bit
Tomcat Version: Apache Tomcat/9.0.30
Lucee Version: Lucee 5.3.4.77 (using installer)

We have successfully relocated the lucee-web-directory by updating /opt/lucee/tomcat/conf/web.xml so that we have a centralized WEB-INF on each server under or main application directory.

<init-param>
      <param-name>lucee-web-directory</param-name>
      <param-value>/X/xxxx/WEB-INF/{web-context-label}/</param-value> 
      <description>Lucee Web Directory (for Website-specific configurations, settings, and libraries)</description>
</init-param>

We are using Apache as our frontend on separate servers using mod_jk to redirect to LUCEE.
We are open to switching to mod_cfml, to make life easier but hey all our scripts are setup to use mod_jk and create virtual hosts on apache and tomcat so why fix it if it ain’t broke. :grinning:

The tomcat virtual hosts currently look like the following

<Host name="client1internal.xxxx.net" appBase="webapps" unpackWARs="false" autoDeploy="false" deployOnStartup="false">
    <Alias>client1.xxxx.net</Alias>
    <Context path="" docBase="/X/xxxx/code_base.root" />
    <Valve className="org.apache.catalina.valves.AccessLogValve" directory="/X/server_configs/tomcat/logs"
               prefix="client1" suffix=".txt"
               pattern="%h %l %u %t &quot;%r&quot; %s %b" />
</Host>
<Host name="client2internal.xxxx.net" appBase="webapps" unpackWARs="false" autoDeploy="false" deployOnStartup="false">
    <Alias>client2.xxxx.net</Alias>
    <Context path="" docBase="/X/xxxx/code_base.root" />
    <Valve className="org.apache.catalina.valves.AccessLogValve" directory="/X/server_configs/tomcat/logs"
               prefix="client2" suffix=".txt"
               pattern="%h %l %u %t &quot;%r&quot; %s %b" />
</Host>

Is there any way that we can accomplish this? We are open to any ideas that would help us accomplish this goal.

Thanks in advance!!

Setup symbolic links at the file system
Setup Tomcat / Lucee / with paths to your symbolically linked directories.

or use a server level mapping…