HAProxy Enterprise Documentation 2.3r1

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/Photon OS
    $ 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
       server spoe-mirror-agent1 localhost:12345
  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:

    MIRROR_OPTIONS="-D -r0 -uhttp://mirror.mysite.com/"
  6. Restart the mirror agent and HAProxy Enterprise:

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

Logging

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

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