HAProxy community

Haproxy use_backend condition (acl) is missing the backend

I have an application which I installed in two servers for balancing issue.

I wanted to route the traffic like below:

server 1: client server 2: admin

server 1 app config: host: port: 5031

server 2 app config: host: port: 5032

Application is same in both servers with same database connection.

I installed haproxy in with port 5033 and setup:

frontend hh-test
        mode tcp
        option tcplog
        acl is_admin path_reg ^/admin/sales$
        use_backend server2 if is_admin
        default_backend server1

backend server2
        mode tcp
        server admin

backend server1
        mode tcp
        server client

It does work. When I access It serves from Server 1 and when I access it serves from server2 …as expected. But some request goes to server1 accessing same /admin/sales url. Very few. I am not sure what I am doing wrong that some request goes to the other backend. Can I have an insight please?

You need to use mode http here, otherwise haproxy cannot reliably extract the URI.

1 Like

I think it is working now. Thank you, thanks a lot. @lukastribus Let me implement it in production and update the solution here.