Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

To some URL I don't want use some server. So use other.

Actually I have this haproxy configuration.

        log   local0
        #log loghost    local0 info
        maxconn 4096
        user haproxy
        group haproxy

        log     global
        mode    http
        option  httplog
        option  dontlognull
        retries 3
        option redispatch
        maxconn 2000
        contimeout      5000
        clitimeout      50000
        srvtimeout      50000
        balance roundrobin

        stats enable
        stats refresh 5s
        stats auth admin:123abc789xyz

# Set up application listeners here.
listen application
  server localhost weight 1 maxconn 5 check
  server externe weight 1 maxconn 5 check

By example I want all url to /users be served only by server localhost, not by externe.

share|improve this question
up vote 3 down vote accepted

We did something similar on our servers. What we did was first to set up a frontend proxy, which using HAProxy's ACL allows to use one or another backend. In your example it could be something like the following:

frontend application

  acl use_localhost path_reg ^/users$

  use_backend localhost if use_localhost

  default_backend externe

backend localhost
  server localhost weight 1 maxconn 5 check

backenb externe
  server externe weight 1 maxconn 5 check

In the example *use_localhost* is the name of the ACL. You can use plenty of different ACLs. I hope this gives you something to start with.

share|improve this answer
thanks, it's exactly what I want. – shingara Nov 20 '10 at 7:55
I have solved this problem using Leandro Lopez' answer, but a heads up to anybody doing this: you need to add the directive option httpclose into any backend definitions that are acl-controlled, otherwise haproxy will re-use the open HTTP connections, possibly sending requests to the wrong backend. (sorry, this really should be a reply to the other answer but i can't seem to leave a reply, only an answer) – notatoad Jun 20 '12 at 20:10

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.