# Haproxy ACL for query-string "Authorization"

**URL:** <https://discourse.haproxy.org/t/haproxy-acl-for-query-string-authorization/7569>\
**Category:** Help!\
**Created:** [April 12, 2022, 4:57pm UTC](https://discourse.haproxy.org/t/haproxy-acl-for-query-string-authorization/7569 "2022-04-12T16:57:50Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![kvvadavi](https://avatars.discourse-cdn.com/v4/letter/k/c77e96/32.png) [@kvvadavi](https://discourse.haproxy.org/u/kvvadavi)\
**Post date:** [April 12, 2022, 4:57pm UTC](https://discourse.haproxy.org/t/haproxy-acl-for-query-string-authorization/7569/1 "2022-04-12T16:57:50Z")

</div>

I am trying to create ACL in Haproxy to query `Authorization` from request header and route to backend based on `AccessID`. I have used `map` file which are populated with `AccessID` and `backend server`. I am sure that my ACL is not working and hence I am getting `503` for incoming requests. Any help is appreciated!

Config File:

```auto
frontend main
        bind *:80
        capture request header Authorization len 50
        acl GET_calls method GET HEAD OPTIONS
        acl PUT_calls method PUT

       use_backend %[req.hdr(Authorization),map_sub(/etc/haproxy/PUT_Header.map)] if PUT_calls

```

Map File:

```auto
# AccessID	backend server
JMYQ get_s1
P2BH get_s1
WEA1 get_s2

```

I have captured the request header in log and I see AccessID.

```auto
Apr 8 10:10:29 localhost haproxy[79517]: 0.11.4.1:929 [08/Apr/2022:10:10:29.232] main main/<NOSRV> -1/-1/-1/-1/0 503 212 - - SC-- 0/0/0/0/0 0/0 {Credential=WEA1} "PUT /common/Demo2.file HTTP/1.1"

```

I was able to get ACL working for individual query.

`acl url_paramf req.hdr(Authorization) -m sub WEA1`

But, map is not working as expected. ACL for Map

`use_backend %[req.hdr(Authorization),map_sub(/etc/haproxy/PUT_Header.map)] if PUT_calls`

---

<div class="post-metadata">

**Author:** ![kvvadavi](https://avatars.discourse-cdn.com/v4/letter/k/c77e96/32.png) [@kvvadavi](https://discourse.haproxy.org/u/kvvadavi)\
**Post date:** [April 13, 2022, 10:24pm UTC](https://discourse.haproxy.org/t/haproxy-acl-for-query-string-authorization/7569/2 "2022-04-13T22:24:18Z")

</div>

I was able to achieve it by doing like this:

```auto
	acl headerlist hdr_sub(Authorization) -f /etc/haproxy/File
	use_backend get_sg1 if headerlist

        acl headerlist2 hdr_sub(Authorization) -f /etc/haproxy/File2
        use_backend get_sg2 if headerlist2

```

File

```auto
# AccessID
JMYQ		
P2BH		

```

File2

```auto
# AccessID
WEA1	

```
