利用ACL匹配访问路径,访问192.168.0.11/a,和192.168.0.11/b时返回不同集群的内容,配置如下
listen web
bind 192.168.0.11:80
mode http
acl static_path_a path_beg -i /a #path_beg匹配URL开头
use_backend static_path_host_a if static_path_a
acl static_path_b path_beg -i /b
use_backend static_path_host_b if static_path_b
backend static_path_host_a
server web1 192.168.0.109:80
backend static_path_host_b
server web1 192.168.0.105:80
当然实际情况backend中有很多提供相同服务的服务器,我在这分别在102.168.0.109和192.168.0.105搭建两台apache进行测试,在默认目录中创建a,b目录,默认页输入不同内容,效果如图
原文:https://blog.51cto.com/12107094/2488875