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:
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:
# AccessID backend server
JMYQ get_s1
P2BH get_s1
WEA1 get_s2
I have captured the request header in log and I see AccessID.
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