Apache mod_proxy balancer config issue with POST request
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
Tomcat 2
Here is what I have in my virtualhost.conf
ProxyRequests on
ProxyPreserveHost Off
ProxyPass / balancer://mycluster/ stickysession=JSESSIONID
ProxyPassReverse / balancer://mycluster/ stickysession=JSESSIONID
ProxyPassReverseCookiePath /myapp /
BalancerMember route=tomcat2
Require all granted
ProxySet lbmethod=byrequests
SetHandler balancer
Require host www.mydomain.com
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
-
Hi, I am trying to set up a Load balancer configuration with Apache and Tomcat. I am on a Virtual Private Server with CentOS 6.9 and I use cPanel. Here is my questions. 1. What are the options I have for load balancing? 2. For Load balancer what is preferred between mod_jk and mod_proxy? Also any other good options? I have found that my configuration doesn't come with mod_jk and noticed that cPanel documentation says it is not recommended because of security reasons. 3. Looks like any changes I make directly to the Apache /usr/local/apache/conf/httpd.conf will be overwritten when any cPanel setting is changed. So what is the best way if we want to modify VirtualHost settings? Where I should make the changes? I have seen several conf files and not sure which is the right one. Also if I need to make any changes outside the VirtualHost entry which is the right file or where should I create the file? When I create the cPanel user those VirtualHost entries are made automatically. So I am assuming in order to configure load balancer, I need update the files manually to have additional attributes in the VirtualHost entry. 4. What is the purpose of the following Apache directories? /usr/local/apache /etc/apache2 /etc/httpd Thanks 0 -
Hello @Tech P, We don't currently support load balancing with cPanel & WHM. Any type of load balancing configuration is unsupported, and thus you'd need to seek out the help of a qualified system administrator if it's not working the way you intend or if you require assistance with the setup. We provide a list of companies offering system admin services at: Note that our feature request website is currently down for maintenance but should resume operation soon. With that said, I'm happy to answer questions related to the cPanel & WHM product itself: . Looks like any changes I make directly to the Apache /usr/local/apache/conf/httpd.conf will be overwritten when any cPanel setting is changed. So what is the best way if we want to modify VirtualHost settings? Where I should make the changes? I have seen several conf files and not sure which is the right one. Also if I need to make any changes outside the VirtualHost entry which is the right file or where should I create the file? When I create the cPanel user those VirtualHost entries are made automatically. So I am assuming in order to configure load balancer, I need update the files manually to have additional attributes in the VirtualHost entry.
We document advanced Apache configuration information (including what to edit to ensure changes are not overwritten) at:0
Please sign in to leave a comment.
Comments
2 comments