HAProxy Enterprise Documentation 2.0r1

Configure Traffic Mirroring

To configure mirroring of traffic:

  1. Install the required packages on the HAProxy Enterprise node:

    $ # On Debian/Ubuntu
    $ sudo apt-get install hapee-extras-spoa-mirror
    $ # On CentOS/RedHat/Oracle
    $ sudo yum install hapee-extras-spoa-mirror
    $ # On SUSE
    $ sudo zypper install hapee-extras-spoa-mirror
    $ # On FreeBSD
    $ sudo pkg install hapee-extras-spoa-mirror
  2. Configure HAProxy Enterprise to send traffic to the agent. Add a filter spoe directive to your frontend, as shown:

    # Production frontend
    frontend fe_main
       mode http
       bind :80
       option http-buffer-request
       default_backend be_servers
       filter spoe  engine mirror  config /etc/hapee-extras/hapee-mirror-spoe.cfg

    This directive specifies the mirror engine name and the mirror configuration file name. We cover these items in a later section.

  3. In addition to the backend that specifies your production servers, add a backend that specifies the server and port of the SPOE mirror agent. Here's an example:

    # Mirror agents
    backend mirroragents
       mode tcp
       balance roundrobin
       timeout connect 5s
       timeout server 5s
       option spop-check
       server spoe-mirror-agent1 127.0.0.1:12345 check

    This example also uses option spop-check, which enables health checking of SPOE agents via the SPOE protocol.

  4. Edit the mirror engine configuration file, /etc/hapee-extras/hapee-mirror-spoe.cfg, specified by the filter spoe directive in the HAProxy Enterprise configuration file.

    Add the following content to the mirror engine configuration file:

    [mirror]
    spoe-agent mirror
        log global
        messages mirror
        use-backend mirroragents
        timeout hello 500ms
        timeout idle 5s
        timeout processing 5s
    
    spoe-message mirror
        args arg_method=method arg_path=url arg_ver=req.ver arg_hdrs=req.hdrs_bin arg_body=req.body
        event on-frontend-http-request

    This file configures how HAProxy Enterprise communicates with the SPOE mirror agent. See the reference.

  5. The agent mirrors data to http://localhost:10100/ by default. To change this URI, edit the file /etc/default/hapee-extras-spoa-mirror.

    Modify the -u option in the MIRROR_OPTIONS environment variable to send traffic to a new URL. You can specify a domain or IP address, with or without a port. Examples:

    MIRROR_OPTIONS="-D -r0 -uhttp://mirror.mysite.com/"
    MIRROR_OPTIONS="-D -r0 -uhttp://192.168.41.10:10100"
    MIRROR_OPTIONS="-D -r0 -uhttp://localhost:8100/"
  6. Enable the mirror agent:

    $ sudo systemctl enable hapee-extras-spoa-mirror
  7. Restart the mirror agent and HAProxy Enterprise:

    $ sudo systemctl restart hapee-extras-spoa-mirror
    $ sudo systemctl restart hapee-2.0-lb

Logging

Mirrored requests are logged to the file /var/log/hapee-2.0r1/lb-access-<date>.log by default.

An example log statement is shown below:

Aug 25 17:48:36 node1 hapee-lb[215242]: SPOE: [mirror] <EVENT:on-frontend-http-request> sid=707 st=0 0/13/8/0/22 1/1 0/0 0/1

Next up

Tuning Mirrored Traffic