How to not redirect when cookie is set in haproxy

cookiehaproxyload balancingmobile-devicesredirect

On my site I redirect users with mobile devices to a mobile site using my Haproxy loadbalancer. I got some complaints about that and want to offer the users a link back to the "classic" portal. As not all sub-pages are available in a mobile format I have to select if the content is available or not first.

    acl path_root path /
    acl path_mobile path_beg /faq
    acl site_classic hdr_sub(cookie) CLASSIC=
    acl ua_smartphone hdr_reg(User-Agent) -i iphone ipod android bada
    redirect location http://s.tld if path_root ua_smartphone !site_classic
    redirect prefix http://s.tld if path_mobile ua_smartphone !site_classic

If the user is entering at the top level directory just redirect the location. If the "mobile" user hits content that is available in mobile format redirect including the full path. This all works fine so far.

Now I do not want to redirect the user anymore when s/he clicked a link in the mobile version that sets a cookie named "CLASSIC".

The cookie is set correctly and works fine. If I write the following the redirection works:

    acl site_classic hdr_sub(cookie) CLASSIC=
    redirect location http://s.tld if site_classic

I also tried all thinkable ways of checking the cookie, e.g. CLASSIC=1 CLASSIC=true CLASSIC=portal etc. and in code

    acl site_classic hdr_sub(cookie) CLASSIC
    acl site_classic hdr_sub(cookie) CLASSIC=
    acl site_classic hdr_sub(cookie) CLASSIC=1
    acl site_classic hdr_sub(cookie) CLASSIC=true
    acl site_classic hdr_sub(cookie) CLASSIC=portal

Why does it not work?

Thank you for your help!

Best Answer

I think you cannot use the same ACL name more than once, try using something like this:

acl site_classic1 hdr_sub(cookie) CLASSIC
acl site_classic2 hdr_sub(cookie) CLASSIC=
acl site_classic3 hdr_sub(cookie) CLASSIC=1
acl site_classic4 hdr_sub(cookie) CLASSIC=true
acl site_classic5 hdr_sub(cookie) CLASSIC=portal

redirect location http://s.tld if site_classic1 or site_classic2 or site_classic3 or site_classic4 or site_classic5