# Inspect ACL value

**URL:** <https://discourse.haproxy.org/t/inspect-acl-value/4033>\
**Category:** Help!\
**Created:** [July 10, 2019, 9:00am UTC](https://discourse.haproxy.org/t/inspect-acl-value/4033 "2019-07-10T09:00:48Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![GrzegorzWiktorowski](https://avatars.discourse-cdn.com/v4/letter/g/7ba0ec/32.png) [@GrzegorzWiktorowski](https://discourse.haproxy.org/u/GrzegorzWiktorowski)\
**Post date:** [July 10, 2019, 9:00am UTC](https://discourse.haproxy.org/t/inspect-acl-value/4033/1 "2019-07-10T09:00:48Z")

</div>

Is it possible to inspect directly the value of ACL clause during runtime? For example having

```
acl srv1 path_dir /site1
acl srv2 path_dir /site2

```

I can only conclude from HAProxy log what is the result of ACLs.

---

<div class="post-metadata">

**Author:** ![ciprian.craciun](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.haproxy.org/ciprian.craciun/32/722_2.png) [@ciprian.craciun](https://discourse.haproxy.org/u/ciprian.craciun)\
**Post date:** [July 10, 2019, 10:00am UTC](https://discourse.haproxy.org/t/inspect-acl-value/4033/2 "2019-07-10T10:00:19Z")

</div>

What do you mean by “inspecting directly”? I.e. give some examples on how you would use such a feature.

You could for example set some headers based on selected ACLs, thus you could see if they are set or not in the request / response. Also you can use `set-var(txn.something)` based on ACLs.

---

<div class="post-metadata">

**Author:** ![GrzegorzWiktorowski](https://avatars.discourse-cdn.com/v4/letter/g/7ba0ec/32.png) [@GrzegorzWiktorowski](https://discourse.haproxy.org/u/GrzegorzWiktorowski)\
**Post date:** [July 10, 2019, 10:20am UTC](https://discourse.haproxy.org/t/inspect-acl-value/4033/3 "2019-07-10T10:20:01Z")

</div>

I mean by “inspecting directly” to write the value to the log file or on the console in -d mode.

---

<div class="post-metadata">

**Author:** ![ciprian.craciun](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.haproxy.org/ciprian.craciun/32/722_2.png) [@ciprian.craciun](https://discourse.haproxy.org/u/ciprian.craciun)\
**Post date:** [July 10, 2019, 10:47am UTC](https://discourse.haproxy.org/t/inspect-acl-value/4033/4 "2019-07-10T10:47:59Z")

</div>

To my knowledge there isn’t any such option.

However you could use a combination of request headers and `capture` statements to see if an ACL is set for a particular HTTP request.

---

<div class="post-metadata">

**Author:** ![GrzegorzWiktorowski](https://avatars.discourse-cdn.com/v4/letter/g/7ba0ec/32.png) [@GrzegorzWiktorowski](https://discourse.haproxy.org/u/GrzegorzWiktorowski)\
**Post date:** [July 10, 2019, 10:56am UTC](https://discourse.haproxy.org/t/inspect-acl-value/4033/5 "2019-07-10T10:56:35Z")

</div>

I will try. Thanks.

---

<div class="post-metadata">

**Author:** ![jl2035](https://avatars.discourse-cdn.com/v4/letter/j/a9a28c/32.png) [@jl2035](https://discourse.haproxy.org/u/jl2035)\
**Post date:** [January 13, 2020, 12:33pm UTC](https://discourse.haproxy.org/t/inspect-acl-value/4033/6 "2020-01-13T12:33:18Z")

</div>

Any ideas? I also want the same thing.

---

<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:** [January 13, 2020, 7:59pm UTC](https://discourse.haproxy.org/t/inspect-acl-value/4033/7 "2020-01-13T19:59:55Z")

</div>

Write whatever you want into a txn variable, based on the ACL:

```
    acl srv1 path_beg /site1
    http-request set-var(txn.srv1acl) str(acl-srv1-site1-match) if srv1
    http-request set-var(txn.srv1acl) str(acl-srv1-site1-nomatch) if ! srv1

```

Then configure logging referring to that variable:

```
    log-format "%{+Q}[var(txn.srv1acl)]"
```

---

<div class="post-metadata">

**Author:** ![jl2035](https://avatars.discourse-cdn.com/v4/letter/j/a9a28c/32.png) [@jl2035](https://discourse.haproxy.org/u/jl2035)\
**Post date:** [January 15, 2020, 8:00am UTC](https://discourse.haproxy.org/t/inspect-acl-value/4033/8 "2020-01-15T08:00:38Z")

</div>

I was successful using headers and captures, but your approach is way more elegant. Thanks!
