I have a Haproxy config that is currently in development and I am using the following code in order to find if the requesting user will accept a cookie or not as the script at the end destination requires cookies for security.

This is the config I am using to set the cookie which works great if the user will adopt the cookie correctly. However, if the end user does not accept the cookie it generates an infinite redirect loop. The Cookie_Block backend is as follows -

backend Cookie_Block
# For this block we will hold the connection for 5 seconds then reject
# The error will display the reason as to why the connection has been denied
mode http
timeout tarpit 5s
errorfile 403 /errors/NoCookie.txt
reqitarpit .

The desired effect that I am aiming for is if the user will not accept the cookie they are tarpitted and have the error returned to them. I was sure the above code would attempt to set the cookie and then tarpit them if the cookie failed to set.. But this does not seem to be the case. Is there something I am doing wrong or an alternative method of doing this without taking the user to a page to set the cookie?

Thanks for your response.. Would you be able to elaborate on this? It runs an infinite redirect even if I put it in listen and won't run in backend.
–
ChrisFeb 10 '11 at 11:38

The event flow goes like this: 1.- Client connects and sends request 2.- haproxy checks for cookie, as its not set tells the client to ask again with the cookie set 3.- The client ignores the cookie and sends again the request. 4.- Go to step 2
–
OchotoFeb 11 '11 at 10:36