Virtual Hosts with Apache, Tomcat, AJP

Here I describe how to configure Apache to handle request for 2 virtual hosts, redirecting the requests to 2 Tomcat installed on the same machine.

Suppose you want to handle 2 applications hello.com and welcome.com.
The DNS points to the same IP address and Apache is listening to port 80.


Apache/2.2.3

Add proxy_ajp.conf in /etc/httpd/conf.d

LoadModule proxy_ajp_module modules/mod_proxy_ajp.so

NameVirtualHost *

<VirtualHost *>
ServerName hello.com
ProxyPass / ajp://localhost:8091/
ProxyPassReverse / ajp://localhost:8091/
</VirtualHost>

<VirtualHost *>
ServerName welcome.com
ProxyPass / ajp://localhost:8090/
ProxyPassReverse / ajp://localhost:8090/
</VirtualHost>


Tomcat 6.0.18

The default configuration of Tomcat 6.0.18 works pretty fine. You just have to change the ports so they don't conflict. I'm using 8090 and 8091 for the 2 APJ Connectors of the 2 Tomcats.

0 commenti: