slash
slash

Reputation: 603

Fronting two tomcat Servers with Apache HTTP server

I am trying to host the two different context (on 2 different tomcat servers) under the same domain. The contexts are related and should be hosted under same domain name. Lets say http://test.com/test1 and http://test.com/test2.

The apache http server already routing the internet traffic to http://test.com/test1 using the below configuration.

<VirtualHost *:80 *:443>
   ServerName test.com
   ProxyRequests Off
<Proxy balancer://test1Bal>
   BalancerMember ajp://tomcat1_host:8009/tomcat1
</Proxy>
    ProxyPass /test1/ balancer://test1Bal/
    ProxyPass / balancer://test1Bal/    
</VirtualHost> 

Is there any way if i hit the URL http://test.com/test2, the apache http server should serve the pages/requests from the tomcat2 server ?

Thank you very much!

Upvotes: 0

Views: 258

Answers (1)

Mark Thomas
Mark Thomas

Reputation: 16615

With a only a single node, you can remove the balancer. You also don't need the ProxyPass line that is redirecting /.

Use the following configuration.

<VirtualHost *:80 *:443>
   ServerName test.com
   ProxyRequests Off
   ProxyPass /test1/ ajp://tomcat1_host:8009/tomcat1
   ProxyPass /test2/ ajp://tomcat2_host:8009/tomcat2
</VirtualHost> 

Upvotes: 1

Related Questions