HAProxy Enterprise Documentation 1.7r1

Log with Docker

When HAProxy Enterprise runs as a Docker container, you can collect logs in the following ways:

  • Forward logs to a remote Syslog server, which can run in a separate container

Log to a syslog container

This method allows you to forward logs to a container running a Syslog server, such as Rsyslog.

  1. Place a log statement into the global section of your configuration file:

    • use the IP address or name of your Syslog container, with an optional port number

    • use local0 as the facility code

    global
      log rsyslog:514 local0
  2. Add a log global statement to a defaults section to enable the global logging rule in all subsequent listen, frontend, and backend sections:

    defaults
      log global
  3. View logs by querying the rsyslog container using the docker logs command:

    $ sudo docker logs rsyslog

HAProxy Enterprise configuration

global
  log rsyslog:514 local0

defaults
  log global

frontend fe_main
  bind :80
  default_backend be_main

backend be_main
  server web1 web1:8080 check

Docker commands

$ # Create Docker network
$ sudo docker network create -d bridge my-network

$ # Run web server container
$ sudo docker run -d --network my-network --name web1 \
    --restart unless-stopped jmalloc/echo-server

$ # Run Rsyslog container
$ sudo docker run -d --network my-network --name rsyslog \
    --restart unless-stopped jumanjiman/rsyslog

$ # Run HAProxy Enterprise container
$ sudo docker run -d --network my-network --name hapee \
    -p 80:80 -p 443:443 --restart unless-stopped \
    -v (pwd):/etc/hapee-1.7 \
    hapee-registry.haproxy.com/hapee-business:1.7r1

Next up

Logging Reference