Haproxy sending request to wrong backend

So we have 2 weeks since we started using Haproxy and everything was working fine. 2 Days ago we added a new frontend acl rule but it doesn’t seem to working correctly.

Whenever we put the url https://www.url.com/quotes it directs the request to the correct backend. But when we use https://www.url.com/quotes-rest-api it directs to the wrong backend. Actually it seems to be using the same backend as the previous one.

This is the configuration we have and the logs

frontend appcliente
bind 172.20.1.96:443 ssl crt /etc/pki/ca-trust/source/anchors/clientes.com.pa.pem
mode http
option httplog
acl url_app path -i -m beg /app-gateway-service-rest
default_backend appc1
acl url_app6 path -i -m beg /validate
use_backend procli if url_app6
cl url_app3 path -i -m beg /banners-gateway-rest-api
use_backend appc2 if url_app3
acl url_app14 path -i -m beg /quote
use_backend procli if url_app14
acl url_app16 path -i -m beg /quotes-gateway-rest-api
use_backend appc2 if url_app16

backend appc1
balance roundrobin
mode http
stats enable
cookie JSESSIONID prefix
server Mngt_APP1 172.17.8.24:9016
server Mngt_APP2 172.17.8.25:9016

backend appc2
balance roundrobin
mode http
stats enable
cookie JSESSIONID prefix
server PROMGNT 10.240.194.189:8081

backend procli
balance roundrobin
mode http
stats enable
cookie JSESSIONID prefix
server PROMGNT 10.240.194.189:8086

###########
Logs
###########

[27/Mar/2023:16:48:03.615] appcliente~ appc2/PROMGNT 45/0/2/504/551 204 73 - - --NN 5/4/0/0/0 0/0 “GET /banners-gateway-rest-api/api/v1/gateway/banners HTTP/1.1”
[27/Mar/2023:16:48:25.410] appcliente~ procli/PROMGNT 273/0/5/6/284 404 250 - - --NN 4/1/0/1/0 0/0 “GET /quotes-gateway-rest-api/api/v1/quotes/departments HTTP/1.1”
###########

Not sure if its because we already have acl rule with the word quote and is using that same rule, but the other acl rule has been specified as “quotes-rest-api…”

I tried to use some rules in the backend like this
reqrep ^([^\ :])\ /prueba(.) \1\ /quotes-gateway-rest-api\2

So whenever someone typed url.com/prueba it redirecto quotes-gateway… but still doesn’t solve the issue.

HA-Proxy version 1.5.18 2016/05/10

Any help appreciated.

Hello,

Rules order is important.

Here you have this rule juste before :

acl url_app14 path -i -m beg /quote
use_backend procli if url_app14

GET /quotes-gateway-rest-api match this rule and is redirected to the wrong backend. Insert the more precise rule first, and it should be OK :

acl url_app16 path -i -m beg /quotes-gateway-rest-api
use_backend appc2 if url_app16
acl url_app14 path -i -m beg /quote
use_backend procli if url_app14

1 Like

I thought that when you specify /quote it will only wait for that specific word and won’t take into consideration what’s after it… I guess it doesn’t work that way.

I made the change in the rules order and both are working fine.

Thanks so much!