用haproxyselect服务器后端到一些URL

到一些URL我不想使用一些服务器。 所以使用其他。

其实我有这个haproxyconfiguration。

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 

举例来说,我想所有的url/用户只能通过本地服务器,而不是externe。

我们在服务器上做了类似的事情。 我们所做的是首先设置一个前端代理,使用HAProxy的ACL允许使用一个或另一个后端。 在你的例子中,它可能如下所示:

 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 

在示例中, use_localhost是ACL的名称。 您可以使用大量不同的ACL 。 我希望这给你一些开始。