BorisS
BorisS

Reputation: 766

Backend routing based on cookie name substring

Example cookie name in request:

wordpress_logged_in_8df6736080e8...

I want to create an haproxy acl based on when the cookie name begins with wordpress_logged_in and then route the logged in users based on that acl to separate backend.

Upvotes: 0

Views: 726

Answers (2)

BorisS
BorisS

Reputation: 766

acl url_admin path_beg -i /wp-admin /wp-login.php
acl url_admin hdr_sub(cookie) wordpress_logged_in

This config is working for me, as it matches the whole cookie header and some URLs. Without the first ACL it's not working.

Upvotes: 1

Aleksandar
Aleksandar

Reputation: 2652

You can try to use cook_beg for the acl

acl cookie_backend cook_beg(wordpress_logged_in) -m found
...
use_backend cookie_backend if cookie_backend
...
default_backend default_backend

This Blog post explains the haproy acl Introduction to HAProxy ACLs
In the doc can you find more details Using ACLs to form conditions

Upvotes: 0

Related Questions