Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

Apache mod_proxy balancer config issue with POST request

Discussion in 'EasyApache' started by Tech P, Apr 7, 2018.

  1. Tech P

    Tech P Registered

    Apr 7, 2018
    Likes Received:
    Trophy Points:
    cPanel Access Level:
    Website Owner
    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.

    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

    <Location /balancer>
    SetHandler balancer
    Require host

    With the above configuration I am able to access the site first page. When I access, it loads the login page(
    When I click on other links it's opening the correct pages. For eg:
    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/ 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
  2. Tech P

    Tech P Registered

    Apr 7, 2018
    Likes Received:
    Trophy Points:
    cPanel Access Level:
    Website Owner
    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?

  3. cPanelMichael

    cPanelMichael Technical Support Community Manager Staff Member

    Apr 11, 2011
    Likes Received:
    Trophy Points:
    cPanel Access Level:
    Root Administrator
    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:

    System Administration Services | cPanel Forums

    Additionally, I encourage you to vote and add feedback to the following feature requests if you'd like to see load balancing supported in cPanel & WHM:

    Server configuration and data auto-sync (mirroring)
    Active-Active Redundancy or High-availability
    Built-in load balancing, replication, high availability

    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:

    We document advanced Apache configuration information (including what to edit to ensure changes are not overwritten) at:

    Advanced Apache Configuration - EasyApache 4 - cPanel Documentation

    The /etc/apache2/ and /usr/local/apache/ directories are where required Apache data is stored (e.g. domain access logs, configuration files). In many cases, data within /usr/local/apache/ is symbolically linked to the corresponding location in the /etc/apache2/ directory. As far as /etc/httpd, it's not a file or directory that's setup by default on cPanel & WHM when using EasyApache 4.

    Thank you.
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice