Scenario: You have application running on two tomcat servers. Example is for localhost. Replcae it with relevant IP addresses which the tomcat servers are runing.
You need to load balance between two tomcat servers through apache server as well as to hide the actualURLs from outside.
Here is the Step by Step instructions.
1. First follow the previous post and configure apache proxy.
2. Let's write a balancer configuration named "mybalancer" with two members who are two tomcat servers. The load should be balanced between those two members (1:1). Add the following segment to httpd.conf file.
3. Now change the ProxyPass statement to refer the balancing cluster. For that replace line
ProxyPass /proxydemo/ http://localhost:8080/app/with
ProxyPass /proxydemo/ balancer://mybalancer
4. Then replace the ProxyPassReverse statement line
ProxyPassReverse /proxydemo/ balancer://mybalancer
What you did was to place the load balancer behind the apache server. So the requests come to http://localhost:9090/proxydemo (assuming Apache runs on port 9090,replace with your own port)will be redirected to either of the balancing members. But the actual URL is hidden to outside.
If you want to access one of the resource hosted on tomcat servers such as
You can access it through apache load balancer through
when someone access the above URL requests will be balanced to one of the members, in this case 1:1. You can shut down one tomcat server and try the above URL. Then it will work as another server is still working. But if you have shut down both servers it will display as server temporaly not available.
Ths example was assuming there are two tomcat servers running on the same machine (port 8080 and port 8090) and apache server is running on port 9090. You can try this on distributed servers and replace localhost with IP addresses.