An SEOs Guide To HAProxy

Introduction To HAProxy

HAProxy is a widely used load balancer, and can produce very detailed logs. It ships with a number of pre-configured log formats; the http format it closest to what the Log File Analyser requires, and looks something like this:

Oct 23 13:09:19 haproxy haproxy[1933]: 10.0.0.22:52648 [23/Oct/2018:13:09:19.467] Local_Server My_Web_Servers/webserver-3 0/0/1/1/2 200 461 - - ---- 2/2/0/1/0 0/0 "GET / HTTP/1.1"

  • Oct 23 13:09:19 haproxy – this comes from the fact that HAProxy logs via syslog, and these fields are ignored by the Log File Analyser
  • haproxy[1933]: – this is the name of the process and its PID, and is ignored by the Log File Analyser
  • 10.0.0.22:52648 – this is the client IP and port
  • [23/Oct/2018:13:09:19.467] – this is the date and time of the request
  • Local_Server – this is the name of the HAProxy frontend, and is ignored by the Log File Analyser
  • My_Web_Servers/webserver-3 – this is the name of the backend the request was sent to, and is ignored by the Log File Analyser
  • 0/0/1/1/2 – this is timing information for things like client-to-haproxy and haproxy-to-backend, and is ignored by the Log File Analyser
  • 200 – this is the response code
  • 461 – this is the response size
  • – – this is the captured request cookie, and is ignored by the Log File Analyser
  • – – this is the captured response cookie, and is ignored by the Log File Analyser
  • —- – this is the session termination state, and is ignored by the Log File Analyser
  • 2/2/0/1/0 – this is information about the number of connections the server had at the time of the request, and is ignored by the Log File Analyser
  • 0/0 – this is queue information, and is ignored by the Log File Analyser
  • “GET / HTTP/1.1” – this is the request line

This format is missing a User-Agent field, which is required by the Log File Analyser. In order to capture this field you need to add capture request header User-Agent len 128 to your frontend section, which will make the log format look something like this:

Oct 23 13:31:46 haproxy haproxy[2248]: 10.0.0.22:54211 [23/Oct/2018:13:31:46.632] Local_Server My_Web_Servers/webserver-1 0/0/0/1/1 200 461 - - ---- 1/1/0/1/0 0/0 {Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/11.1.2 Safari/605.1.15} "GET / HTTP/1.1"

As you can see, this is mostly the same as the original format, but it now includes the User-Agent: {Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/11.1.2 Safari/605.1.15}

Full documentation for HAProxy logs files can be found on their website

  • Like us on Facebook
  • +1 us on Google Plus
  • Connect with us on LinkedIn
  • Follow us on Twitter
  • View our RSS feed

Download.

Download

Purchase a licence.

Purchase