title: forward requests to cpanel server through haproxy
body: <p>I deployed an loadbalanced infrustructure. I am using haproxy as the loadbalancer and cpanel as backend webservers. I created a test host on the cpanel, and I can see the site in browser when I configure the website in my /etc/host with the cpanel server ip address. But when I change the ip to the loadbalancer it forwards the requests to /usr/local/apache/htdocs/ and I get the default cpanel server page. What configurations should I use in haproxy to redirects requests correctly?
  Any help is appreciated.</p>
  
  <pre><code># Global settings
  #---------------------------------------------------------------------
  global
      log         127.0.0.1 local2     #Log configuration
  
      chroot      /var/lib/haproxy
      pidfile     /var/run/haproxy.pid
      maxconn     4000
      user        haproxy             #Haproxy running under user and group "haproxy"
      group       haproxy
      daemon
  
      # turn on stats unix socket
      stats socket /var/lib/haproxy/stats
  
  #---------------------------------------------------------------------
  # common defaults that all the 'listen' and 'backend' sections will
  # use if not designated in their block
  #---------------------------------------------------------------------
  defaults
      mode                    http
      log                     global
      option                  httplog
      option                  dontlognull
      option http-server-close
      option forwardfor       except 127.0.0.0/8
      option                  redispatch
      retries                 3
      timeout http-request    10s
      timeout queue           1m
      timeout connect         10s
      timeout client          1m
      timeout server          1m
      timeout http-keep-alive 10s
      timeout check           10s
      maxconn                 3000
  
  #---------------------------------------------------------------------
  #HAProxy Monitoring Config
  #---------------------------------------------------------------------
  listen haproxy2-monitoring *:8080                #Haproxy Monitoring run on port 8080
      mode http
   option forwardfor
      option httpclose
      stats enable
      stats show-legends
      stats refresh 5s
      stats uri /stats                             #URL for HAProxy monitoring
      stats realm Haproxy\ Statistics
      stats auth lb2:F6khdTrt9g            #User and Password for login to the monitoring dashboard
      stats admin if TRUE
      default_backend app-main                    #This is optionally for monitoring backend
  
  #---------------------------------------------------------------------
  # FrontEnd Configuration
  #---------------------------------------------------------------------
  frontend main
      bind *:80
      default_backend app-main
  
  #---------------------------------------------------------------------
  # BackEnd roundrobin as balance algorithm
  #---------------------------------------------------------------------
  backend app-main
  
  
      balance roundrobin                                     #Balance algorithm
      application is up and healty - 200 status code
  
      server cpanel1 192.168.1.110:80 check
      server cpanel2 192.168.1.111:80 check
  
  Cpanel apache config:
  Listen 0.0.0.0:80
  
  # BEGIN: HTTP vhosts list
  
  &lt;VirtualHost 88.99.219.13:80&gt;
    ServerName wiki.serversetup.ir
    ServerAlias mail.wiki.serversetup.ir www.wiki.serversetup.ir
    DocumentRoot /home/wiki/public_html
    ServerAdmin webmaster@wiki.serversetup.ir
    UseCanonicalName Off
    CustomLog /etc/apache2/logs/domlogs/wiki.serversetup.ir combined
    &lt;IfModule log_config_module&gt;
      &lt;IfModule logio_module&gt;
        CustomLog /etc/apache2/logs/domlogs/wiki.serversetup.ir-bytes_log "%{%s}t %I .\n%{%s}t %O ."
      &lt;/IfModule&gt;
    &lt;/IfModule&gt;
    ## User wiki # Needed for Cpanel::ApacheConf
    &lt;IfModule userdir_module&gt;
      &lt;IfModule !mpm_itk.c&gt;
        &lt;IfModule !ruid2_module&gt;
          UserDir disabled
          UserDir enabled wiki
        &lt;/IfModule&gt;
      &lt;/IfModule&gt;
    &lt;/IfModule&gt;
  
    # Enable backwards compatible Server Side Include expression parser for Apache versions &gt;= 2.4.
    # To selectively use the newer Apache 2.4 expression parser, disable SSILegacyExprParser in
    # the user's .htaccess file.  For more information, please read:
    #    http://httpd.apache.org/docs/2.4/mod/mod_include.html#ssilegacyexprparser
    &lt;IfModule include_module&gt;
      &lt;Directory "/home/wiki/public_html"&gt;
        SSILegacyExprParser On
      &lt;/Directory&gt;
    &lt;/IfModule&gt;
  
  
  
    &lt;IfModule suphp_module&gt;
      suPHP_UserGroup wiki wiki
    &lt;/IfModule&gt;
    &lt;IfModule suexec_module&gt;
      &lt;IfModule !mod_ruid2.c&gt;
        SuexecUserGroup wiki wiki
   &lt;/IfModule&gt;
    &lt;/IfModule&gt;
    &lt;IfModule ruid2_module&gt;
      RMode config
      RUidGid wiki wiki
    &lt;/IfModule&gt;
    &lt;IfModule mpm_itk.c&gt;
      # For more information on MPM ITK, please read:
      #   http://mpm-itk.sesse.net/
      AssignUserID wiki wiki
    &lt;/IfModule&gt;
  
    &lt;IfModule alias_module&gt;
      ScriptAlias /cgi-bin/ /home/wiki/public_html/cgi-bin/
    &lt;/IfModule&gt;
  
  
    # To customize this VirtualHost use an include file at the following location
    # Include "/etc/apache2/conf.d/userdata/std/2_4/wiki/wiki.serversetup.ir/*.conf"
  &lt;/VirtualHost&gt;
  # END: HTTP vhosts list
  </code></pre>