I am trying to setup a Load balancer with Apache mod_proxy and Tomcat.
I have the following modules available (mod_proxy, mod_proxy_balancer, mod_proxy_http)
I have 2 Tomcat instances and the plan is to route the request to one of the Tomcat server.
My application on Tomcat is running fine when I directly access.
www.mydomain:8080/myapp
www.mydomain:9080/myapp
My Tomcat server.xml has the following
Tomcat 1
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
<Engine name="Catalina" defaultHost="localhost" jvmRoute="tomcat1">
Tomcat 2
<Connector port="9009" protocol="AJP/1.3" redirectPort="9443" />
<Engine name="Catalina" defaultHost="localhost" jvmRoute="tomcat2">
Here is what I have in my virtualhost.conf
<IfModule proxy_module>
ProxyRequests on
ProxyPreserveHost Off
ProxyPass / balancer://mycluster/ stickysession=JSESSIONID
ProxyPassReverse / balancer://mycluster/ stickysession=JSESSIONID
ProxyPassReverseCookiePath /myapp /
<Proxy balancer://mycluster >
BalancerMember http://localhost:8080/myapp route=tomcat1
BalancerMember http://localhost:9080/myapp route=tomcat2
Require all granted
ProxySet lbmethod=byrequests
</Proxy>
<Location /balancer>
SetHandler balancer
Require host www.mydomain.com
</Location>
</IfModule>
With the above configuration I am able to access the site first page. When I access www.mydomain.com, it loads the login page(www.mydomain.com/login.do)
When I click on other links it's opening the correct pages. For eg: www.mydomain.com/password-reset.do
The basic fail over also works. If I shutdown one Tomcat Instances, it serves the page from the other server and vice versa.
But when I try to submit any POST requst like try to Login, the url change to www.mydomain/myapp/login.do and always shows the login page.
I am not sure the above conf entries are fully correct with respect to what I want.
Can some one points me what is wrong. Also please let me know if I am lacking anything here with respect to sucurity.
I also would like to have image files and other files served directly from the Webserver. Please let me know how I can do that.
Thanks in advance
I have the following modules available (mod_proxy, mod_proxy_balancer, mod_proxy_http)
I have 2 Tomcat instances and the plan is to route the request to one of the Tomcat server.
My application on Tomcat is running fine when I directly access.
www.mydomain:8080/myapp
www.mydomain:9080/myapp
My Tomcat server.xml has the following
Tomcat 1
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
<Engine name="Catalina" defaultHost="localhost" jvmRoute="tomcat1">
Tomcat 2
<Connector port="9009" protocol="AJP/1.3" redirectPort="9443" />
<Engine name="Catalina" defaultHost="localhost" jvmRoute="tomcat2">
Here is what I have in my virtualhost.conf
<IfModule proxy_module>
ProxyRequests on
ProxyPreserveHost Off
ProxyPass / balancer://mycluster/ stickysession=JSESSIONID
ProxyPassReverse / balancer://mycluster/ stickysession=JSESSIONID
ProxyPassReverseCookiePath /myapp /
<Proxy balancer://mycluster >
BalancerMember http://localhost:8080/myapp route=tomcat1
BalancerMember http://localhost:9080/myapp route=tomcat2
Require all granted
ProxySet lbmethod=byrequests
</Proxy>
<Location /balancer>
SetHandler balancer
Require host www.mydomain.com
</Location>
</IfModule>
With the above configuration I am able to access the site first page. When I access www.mydomain.com, it loads the login page(www.mydomain.com/login.do)
When I click on other links it's opening the correct pages. For eg: www.mydomain.com/password-reset.do
The basic fail over also works. If I shutdown one Tomcat Instances, it serves the page from the other server and vice versa.
But when I try to submit any POST requst like try to Login, the url change to www.mydomain/myapp/login.do and always shows the login page.
I am not sure the above conf entries are fully correct with respect to what I want.
Can some one points me what is wrong. Also please let me know if I am lacking anything here with respect to sucurity.
I also would like to have image files and other files served directly from the Webserver. Please let me know how I can do that.
Thanks in advance