Switch backend when path_reg matches regex


#1

Hi,

I would like to switch to a different backend when the path_reg regex matches a name but the request always go to the normal backend sslnodes instead of the backend blognodes, so there must be something i’m doing wrong. I currently have the following configuration;

HTTP Load Balancing Configuration

frontend sslweb
bind 192.168.1.81:80
bind 192.168.1.81:443 ssl crt /etc/ssl/certs/haproxy.pem
redirect scheme https if !{ ssl_fc }
acl host_apache hdr(host) -i www.example.com
acl msg-url-blog path_reg /(admin|plaap|poekoe|prrt)/( *. )
use_backend blognodes if host_apache msg-url-blog
mode http
default_backend sslnodes

backend sslnodes
mode http
option httplog
balance roundrobin
option forwardfor
option httpchk HEAD / HTTP/1.1\r\nHost:sslnodes
stick-table type ip size 20k peers peerhosts
# HSTS (15768000 seconds = 6 months)
rspadd Strict-Transport-Security:\ max-age=15768000
server web01 192.168.1.10:80 check
server web02 192.168.1.11:80 check

backend blognodes
mode http
option httplog
balance roundrobin
option forwardfor
option httpchk HEAD / HTTP/1.1\r\nHost:blognodes
server web03 192.168.1.12:80 check
server web04 192.168.1.13:80 check

peers peerhosts
peer lb02.example.com 192.168.1.241:1026
peer lb01.example.com 192.168.1.240:1026

Please advise,

Thanks,


#2

Can you log the values of the ACLs? I am guessing the ACL is not evaluating to true. You might have to escape the / in your regex.