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!

  • Is there a reason you're not using req.cook or it's derivatives to look for the cookie in the request? – GregL Jan 24 '15 at 20:00

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
| improve this answer | |
  • 1
    You can actually, it just adds the extra criteria to the ACL. This is outlined in section 7.1 of the manual. Assuming, of course, you're running 1.5. I'm not sure if this behaviour applies to previous versions as well. – GregL Jan 24 '15 at 19:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.