ACL and redirection backend with specific word in path


I hope to use the right terms for my explanation of the configuration I’m trying to operating with HAProxy.

I wish I could tell HAPROXY to detect 2 words in the URL and then redirect to the right backend.

The config works well when I configure it for only one of the 3 environments but as soon as I add a second one it no longer works.

This is basically what I would like to see working:

the user or request types:

and ask to HAProxy to detect the word DEV and SOMETHING to redirect to the good backend (working if having this config only)

But if I add a second environment

and ask to HAProxy to detect the word QA and SOMETHING to another backend it stop working.

The special thing is I have presently the actual server (oldserver) who use, and

So I need to ask HAProxy to detect two word to redirect to specific backend and the old server working.

here my config of the file haproxy.cfg.


Global settings


    log local0
    chroot          /var/lib/haproxy
    pidfile         /run/
    maxconn         4000
    stats socket    /var/lib/haproxy/stats
stats socket /var/run/haproxy.sock mode 600 expose-fd listeners level user

#defaults settings
mode http
log global
option httplog
timeout connect 10s
timeout client 1m
timeout server 1m
errorfile 400 /etc/haproxy/errorfiles/400.http
errorfile 403 /etc/haproxy/errorfiles/403.http
errorfile 408 /etc/haproxy/errorfiles/408.http
errorfile 500 /etc/haproxy/errorfiles/500.http
errorfile 502 /etc/haproxy/errorfiles/502.http
errorfile 503 /etc/haproxy/errorfiles/503.http
errorfile 504 /etc/haproxy/errorfiles/504.http

#Frontend settings

frontend haproxy
bind *:80

acl 	dev_something 		path_sub  dev something 
acl	qa_something	                path_sub  qa something 

use_backend backend_oldserver-qa if { path -i -m beg /qa/ } !qa_something
use_backend backend_newserver-qa if qa_something

use_backend backend_oldserver-dev if { path -i -m beg /dev/ } !dev_something
use_backend backend_newserverdev if essairoutesybase_dev

#Backend settings
backend backend_oldserver-qa

server oldqa1 check
    server oldqa2 check backup

backend backend_newserver-qa
balance roundrobin

    server newqa1 check
server newqa2 check

backend backend_oldserver-dev

    server olddev

backend backend_newserver-dev

server newdev check

#End of haproxy.cfg

So I think that I can’t create two ACL path_sub with the same word (something)

And if my understandings of ACL is good, I can’t use path_beg to detect /dev/test/something/
or path_dir too (I test it and no good result)

thank you in advance for anyone who try to help me

I am not too sure about what it is exactly you are trying to do.

But I suggest using 2 acls, and combining them as conditions. It would probably be the simplest option.