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.

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

Actually I have this haproxy configuration.

global                                                                                                                                                                             
        daemon
        log 127.0.0.1   local0
        #log loghost    local0 info
        maxconn 4096
        #debug
        #quiet
        user haproxy
        group haproxy

defaults
        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 0.0.0.0:10000
  server localhost 127.0.0.1:10100 weight 1 maxconn 5 check
  server externe 127.0.0.1:10101 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

1 Answer 1

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
  bind 0.0.0.0:10000

  acl use_localhost path_reg ^/users$

  use_backend localhost if use_localhost

  default_backend externe

backend localhost
  server localhost 127.0.0.1:10100 weight 1 maxconn 5 check

backenb externe
  server externe 127.0.0.1:10101 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
1  
thanks, it's exactly what I want. –  shingara Nov 20 '10 at 7:55
2  
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

 
discard

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.