ACL based on HTTP Response Set-Cookie Header


#1

Hi guys,

I am currently trying to create an ACL based on the value of the Set-Cookie Header of an HTTP Response given by one of the backend servers. Based on this, being the response an HTTP 301 Moved Permanently, I need to change the Location to which the browser will be then redirected.

This is how it looks right now:

frontend http_front:



acl is_new_bck hdr(Set-Cookie) -m sub value=cookie_1
rspirep ^Location:\ https://www.example.com(.*) Location:\ https://ww2.example.com/ if is_new_bck

However, I am getting the following error:
“acl ‘is_new_bck’ will never match because it only involves keywords that are incompatible with 'frontend http-response header rule”

Can someone help me with this? Where should I put this check? The rspirep works fine. What I need is how to configure the ACL rule.

Thanks!


#2

I think this should be res.hdr instead of hdr, so haproxy knows that it needs to look for this header in the response.

So:
acl is_new_bck res.hdr(Set-Cookie) -m sub value=cookie_1