title: haproxy heartbeat with backend based on http post
body: <p>I want to create a configuration such that the heartbeat between haproxy and the backend is based on HTTP POST.</p>
  
  <p>Does anyone have any idea about this?
  I have tried the below configuration, but it only sent the http HEAD to the backend server (I want HTTP POST):</p>
  
  <pre><code>backend mlp
      mode http
      balance     roundrobin
      server  mlp1 192.168.12.165:9210 check
      server  mlp2 192.168.12.166:9210 check
  </code></pre>
  
  <p>Thanks for your help.</p>
  
  <p>@Mohsin,
      Thank you so much. I indeed work. 
  But I want to specify the request message, seems my configure doesn't work. I appreciate that if you can help too.</p>
  
  <p>[root@LB_vAPP_1 tmp]# more /var/www/index.txt </p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>POST / HTTP/1.1\r\nHost: 176.16.0.8:2234\r\nContent-Length: 653\r\n\r\n&lt;?xml version=\"1.0\" encoding=\"gb2312\"?&gt;\r\n&lt;svc_init ver=\"3.2.0\"&gt;\r\n&lt;hdr ver=\"3.2.0\"&gt;\r\n&lt;client&gt;\r\n&lt;id&gt;915948&lt;/id&gt;\r\n&lt;pwd&gt;915948&lt;/pwd&gt;\r\n&lt;serviceid&gt;&lt;/serviceid&gt;\r\n&lt;/client&gt;\r\n&lt;requestor&gt;&lt;id&gt;13969041845&lt;/id&gt;&lt;/requestor&gt;\r\n&lt;/hdr&gt;\r\n&lt;slir ver=\"3.2.0\" res_type=\"SYNC\"&gt;\r\n&lt;msids&gt;&lt;msid enc=\"ASC\" type=\"MSISDN\"&gt;00000000000&lt;/msid&gt;&lt;/msids&gt;\r\n&lt;eqop&gt;\r\n&lt;resp_req type=\"LOW_DELAY\"/&gt;\r\n&lt;hor_acc&gt;200&lt;/hor_acc&gt;\r\n&lt;/eqop&gt;\r\n&lt;geo_info&gt;\r\n&lt;CoordinateReferenceSystem&gt;\r\n&lt;Identifier
  &gt;\r\n&lt;code&gt;4326&lt;/code&gt;\r\n&lt;codeSpace&gt;EPSG&lt;/codeSpace&gt;\r\n&lt;edition&gt;6.1&lt;/edition&gt;\r\n&lt;/Identifier\r\n&lt;/CoordinateReferenceSystem&gt;\r\n&lt;/geo_info&gt;\r\n&lt;loc_type type=\"CURRENT_OR_LAST\"/&gt;\r\n&lt;prio type=\"HIGH\"/&gt;\r\n&lt;/slir&gt;\r\n&lt;/svc_init&gt;\r\n\r\n\r\n\r\n</code></pre>
  </div>
  </div>
  </p>
  
  <p>my haproxy.conf file is as bellowing:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>#---------------------------------------------------------------------
  # Example configuration for a possible web application.  See the
  # full configuration options online.
  #
  #   http://haproxy.1wt.eu/download/1.4/doc/configuration.txt
  #
  #---------------------------------------------------------------------
  
  #---------------------------------------------------------------------
  # Global settings
  #---------------------------------------------------------------------
  global
      # to have these messages end up in /var/log/haproxy.log you will
      # need to:
      #
      # 1) configure syslog to accept network log events.  This is done
      #    by adding the '-r' option to the SYSLOGD_OPTIONS in
      #    /etc/sysconfig/syslog
      #
      # 2) configure local2 events to go to the /var/log/haproxy.log
      #   file. A line like the following can be added to
      #   /etc/sysconfig/syslog
      #
      #    local2.*                       /var/log/haproxy.log
      #
      log         127.0.0.1 local7
  
      chroot      /var/lib/haproxy
      pidfile     /var/run/haproxy.pid
      ulimit-n 65536
      daemon
      nbproc 1
      # turn on stats unix socket
      stats socket /var/lib/haproxy/stats
  defaults
      mode                    tcp
      retries                 3
      log                     global
      option                  redispatch
  #    option                 abortonclose
      retries                 3
      timeout queue           28s
      timeout connect         28s
      timeout client          28s
      timeout server          28s
      timeout check           1s
      maxconn                 32000
  
  #---------------------------------------------------------------------
  # main frontend which proxys to the backends
  #---------------------------------------------------------------------
  frontend  mlp
      mode                tcp
      option                      persist
  #    bind                       10.68.97.42:9211 ssl crt /etc/ssl/server.pem
     #bind                        10.68.97.42:9211
      bind                        10.68.97.42:9210
      default_backend             mlp
  
  frontend  supl
      mode                        tcp
      option                      persist
      bind                        10.68.97.42:7275
      default_backend             supl
  #-------------
  # option1 http check
  #------------
  backend mlp
      mode http
      balance     roundrobin
   option                      httpchk POST / HTTP/1.1\r\nHost: 176.16.0.8:2234\r\nContent-Length: 653\r\n\r\n{&lt;?xml version=\"1.0\" encoding=\"gb2312\"?&gt;\r\n&lt;svc_init ver=\"3.2.0\"&gt;\r\n&lt;hdr ver=\"3.2.0\"&gt;\r\n&lt;client&gt;\r\n&lt;id&gt;915948&lt;/id&gt;\r\n&lt;pwd&gt;915948&lt;/pwd&gt;\r\n&lt;serviceid&gt;&lt;/serviceid&gt;\r\n&lt;/client&gt;\r\n&lt;requestor&gt;&lt;id&gt;13969041845&lt;/id&gt;&lt;/requestor&gt;\r\n&lt;/hdr&gt;\r\n&lt;slir ver=\"3.2.0\" res_type=\"SYNC\"&gt;\r\n&lt;msids&gt;&lt;msid enc=\"ASC\" type=\"MSISDN\"&gt;00000000000&lt;/msid&gt;&lt;/msids&gt;\r\n&lt;eqop&gt;\r\n&lt;resp_req type=\"LOW_DELAY\"/&gt;\r\n&lt;hor_acc&gt;200&lt;/hor_acc&gt;\r\n&lt;/eqop&gt;\r\n&lt;geo_info&gt;\r\n&lt;CoordinateReferenceSystem&gt;\r\n&lt;Identifier&gt;\r\n&lt;code&gt;4326&lt;/code&gt;\r\n&lt;codeSpace&gt;EPSG&lt;/codeSpace&gt;\r\n&lt;edition&gt;6.1&lt;/edition&gt;\r\n&lt;/Identifier&gt;\r\n&lt;/CoordinateReferenceSystem&gt;\r\n&lt;/geo_info&gt;\r\n&lt;loc_type type=\"CURRENT_OR_LAST\"/&gt;\r\n&lt;prio type=\"HIGH\"/&gt;\r\n&lt;/slir&gt;\r\n&lt;/svc_init&gt;\r\n\r\n\r\n\r\n}
      http-check                  expect  rstring &lt;result resid=\"4\"&gt;UNKNOWN SUBSCRIBER&lt;/result&gt;
      server  mlp1 192.168.12.165:9210 check
      server  mlp2 192.168.12.166:9210 check
      #server  mlp2 192.168.12.166:9210 check 
  
  
  backend supl
      mode tcp
          source  0.0.0.0 usesrc clientip
      balance     roundrobin
      server  supl1 192.168.12.165:7275 check
      server  supl2 192.168.12.166:7275 check
     #server  supl2 192.168.12.166:7275 check</code></pre>
  </div>
  </div>
  </p>