# How to setup authentication attempts logs

**URL:** <https://discourse.haproxy.org/t/how-to-setup-authentication-attempts-logs/2941>\
**Category:** Help!\
**Created:** [September 4, 2018, 10:05am UTC](https://discourse.haproxy.org/t/how-to-setup-authentication-attempts-logs/2941 "2018-09-04T10:05:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mariaczi](https://avatars.discourse-cdn.com/v4/letter/m/aeb1de/32.png) [@mariaczi](https://discourse.haproxy.org/u/mariaczi)\
**Post date:** [September 4, 2018, 10:05am UTC](https://discourse.haproxy.org/t/how-to-setup-authentication-attempts-logs/2941/1 "2018-09-04T10:05:50Z")

</div>

My haproxy config file looks like (important part - I think):

```
global
    log /dev/log local0
    log /dev/log local1 notice
defaults
        log global
        mode http
        option httplog
        option dontlognull
userlist users
  user user insecure-password userpass

frontend front-test
  bind 127.0.0.1:88
  capture request header origin len 128
  capture request header Host len 500
  capture request header User-Agent len 64
  capture request header Authorization len 64
  log-format "%ci:%cp [%t] %H %HP %hr %hrl"
  use_backend bk_test

backend bk_test
  acl auth_ok http_auth(user)
  http-request auth if !auth_ok
  option httpchk GET /
  server local 127.0.0.1:80

```

How to setup to have information about which user name and from which IP tried to authenticate - correct and incorrect auth attempts?

---

<div class="post-metadata">

**Author:** ![lukastribus](https://avatars.discourse-cdn.com/v4/letter/l/7ea924/32.png) [@lukastribus](https://discourse.haproxy.org/u/lukastribus)\
**Post date:** [September 4, 2018, 12:15pm UTC](https://discourse.haproxy.org/t/how-to-setup-authentication-attempts-logs/2941/2 "2018-09-04T12:15:55Z")

</div>

The logging configuration already contains the Authorization header, which contains both username and password base64 encoded.

And you can log the username with the [http\_auth\_group](http://cbonte.github.io/haproxy-dconv/1.6/configuration.html#7.3.6-http_auth_group) fetch, but only if the authentication succeeds (put `%[http_auth_group(users)]` into your custom log format).

---

<div class="post-metadata">

**Author:** ![mariaczi](https://avatars.discourse-cdn.com/v4/letter/m/aeb1de/32.png) [@mariaczi](https://discourse.haproxy.org/u/mariaczi)\
**Post date:** [September 4, 2018, 2:22pm UTC](https://discourse.haproxy.org/t/how-to-setup-authentication-attempts-logs/2941/3 "2018-09-04T14:22:44Z")

</div>

Good point! Thanks. Should be enough for that what I need.
