Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

We have setup a loadbalancer to balance 2 servers. The config looks like this:

    maxconn 40960
    user haproxy
    group haproxy

    log     global
    option  dontlognull
    retries 3
    #option redispatch
    timeout client 10s
    timeout server 10s
    timeout connect 4s
    maxconn 40960

listen webpool lbIP:80
    mode http
    cookie SERVERID insert indirect
    balance roundrobin
    server slave1 slave1IP:80 cookie A check port 8981
    server slave2 slave2IP:80 cookie B check port 8982

The servers slave1 and slave2 needs digest authentication. When the client sends a request the first request is balanced to slave1. This returns a 401: Unauthorized. The second request is balanced to slave2 and will succeed, it returns a 200: OK. The problem is that the authentication always happens on slave1 and the the response always came from slave2. I want both requests(authentication and returning data) into one connection/slave.

Is it possible to configure this in HAproxy?

share|improve this question

1 Answer 1

If I understood you well, you can try using a different balancing algorithm balance source instead of roundrobin. Using this algorithm, all the requests from the same IP will go the same backend server (unless that server is down). This can distribute the load between your backend servers evenly depending on your clients IP addresses.

share|improve this answer
Yes, i tried that before. The problem is the requests came from 1 client/website. When i use "balance source" it will only use slave1. –  John Jan 13 '12 at 14:07

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.