如何使用HAProxy根据主机名转移stream量?

我已经在HAProxy上创build了一些初始的成功,build立了一系列监听其他端口的应用服务器。

我现在有另一个Web服务器监听一个端口,我想要做什么改变,以我的configurationstream量通过主机名以及。

以下是目前的设置,假设:

  • 我的Apache Web服务器运行在examplecom:8001
  • 我的一堆应用程序服务器0.0.0.0:8081,0.0.0.0:8082,0.0.0.0:8083
global log 127.0.0.1 local0 log 127.0.0.1 local1 notice maxconn 4096 debug #quiet #user haproxy #group haproxy defaults log global mode http option httplog option dontlognull retries 3 redispatch maxconn 2000 contimeout 5000 clitimeout 50000 srvtimeout 50000 listen appservers 0.0.0.0:80 mode http balance roundrobin option httpclose option forwardfor #option httpchk HEAD /check.txt HTTP/1.0 server inst1 0.0.0.0:8081 cookie server01 check inter 2000 fall 3 server inst2 0.0.0.0:8082 cookie server02 check inter 2000 fall 3 server inst3 0.0.0.0:8083 cookie server01 check inter 2000 fall 3 server inst4 0.0.0.0:8084 cookie server02 check inter 2000 fall 3 capture cookie vgnvisitor= len 32 

(欢迎任何有关^设置的其他意见。)

现在我想继续上面的,但另外的情况下 – 如果主机名是myspecialtopleveldomain <dot> com,然后想要stream量到示例<dot> com:8001

一B

这里是一个例子:

 frontend http bind 0.0.0.0:80 default_backend www # NAT static host names and static paths in other hostnames to a different backend acl host_static hdr_beg(host) -i static. acl url_static path_beg /static use_backend static if host_static or url_static backend www balance roundrobin server qa1 10.177.1.81:80 server qa2 10.177.1.45:80 backend static balance roundrobin server media1 10.177.0.86:80