2

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.

1 Answer 1

3

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.

1
  • 3
    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) Commented Jun 20, 2012 at 20:10

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.