HAProxy community

How to capture Cookies in haproxy http logs


#1

Hello all,

I am trying to configure http logs for haproxy. I am able to capture the all the required details except cookies. I am very new to haproxy and not have much knowledge. in haproxy official document I found below command to use in front end,

capture cookie “name” len 32

I am confused what to give at “name” field ? is any predefined names exist like for capturing headers or do I need to explicitly define the name of the cookie in ACL and then use here ?

your help means alot for me :slight_smile:

Thanks,
Sandeep Uppala


#2

You need to explicitly specify the name of the cookie that you want to log. This is because you are accessing a specific cookie, as per:

https://cbonte.github.io/haproxy-dconv/1.8/configuration.html#4.2-capture%20cookie

If you want to log the entire cookie header, capture the header instead.


#3

thank you so much for for the quick reply, I am able to capture cookie header now. Well I am actually trying to log session id of each request. can you please help me if any specific way that can help to track this ?

Thanks,
Sandeep Uppala


#4

Capture the exact cookie that contains the session ID, as simple as that.


#5

Thank you and sorry for the late reply.

Here is the issue , we have multiple cookies for each project and in which project-name.sid is carrying session ids.

if I want to capture only .sid cookies, how can I achieve them ?
have tried below, But it didn’t worked.
capture cookie *.sid len 32

each log contains only one "project-name.sid ".

Thanks in advance,

Sandeep Uppala