Tomcat/tc Server is configured for multiple name-based virtual hosts, each serving its own set of web applications. This article provides information on configuring an Apache proxy server to forward requests to a backend Tomcat/tc Server instance so that each set of web applications is served by its respective virtual host only.
This example shows how to configure an Apache proxy server to forward requests to a single back-end Tomcat/tc Server instance with multiple name-based virtual hosts. In this example, mod_proxy is used to forward the requests.
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot /www/ns_vhost1
ServerName www.ns_vhost1.com
ErrorLog logs/ns_vhost1_error.log
TransferLog logs/ns_vhost1_access.log
ProxyPass / http://ns_tomcat_vhost1:8080/
ProxyPassReverse / http://ns_tomcat_vhost1:8080/
</VirtualHost>
<VirtualHost *:80>
DocumentRoot /www/ns_vhost2
ServerName www.ns_vhost2.com
ErrorLog logs/ns_vhost2_error.log
TransferLog logs/ns_vhost2_access.log
ProxyPass / http://ns_tomcat_vhost2:8080/
ProxyPassReverse / http://ns_tomcat_vhost2:8080/
</VirtualHost>
<VirtualHost *:80>
DocumentRoot /www/ns_vhost3
ServerName www.ns_vhost3.com
ErrorLog logs/ns_vhost3_error.log
TransferLog logs/ns_vhost3_access.log
ProxyPass / http://ns_tomcat_vhost3:8080/
ProxyPassReverse / http://ns_tomcat_vhost3:8080/
</VirtualHost>
In order for the Apache index document to be remapped to the ROOT context on the Tomcat/tc Server side, there should be a ROOT web application context for each Tomcat/tc Server virtual host.