ACL and redirection backend with specific word in path

Hi,

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:

server.com/dev/test/something/example

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

server.com/qa/test/something/example

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 server.com/prod/test, server.com/qa/test and server.com/dev.

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

#---------------------------------------------------------------------
global

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

#---------------------------------------------------------------------
#defaults settings
#---------------------------------------------------------------------
defaults
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 192.168.1.2:8080 check
    server oldqa2 192.168.1.3:8080 check backup

backend backend_newserver-qa
balance roundrobin

    server newqa1 192.168.1.4:8080 check
server newqa2 192.168.1.5:8080 check

backend backend_oldserver-dev

    server olddev 192.168.1.6:8080

backend backend_newserver-dev

server newdev 192.168.1.7:8080 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.