Haproxy通过acl';s实现不同后端的负载平衡web集群

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Haproxy通过acl';s实现不同后端的负载平衡web集群相关的知识,希望对你有一定的参考价值。

How to send load-balanced requests to a web cluster and split the requests to different server pools based on specific ACL rules.

This configuration sends files ending with .php to a pool of "dynamic" web servers (running Apache).

It sends all other files (.js, .jpg, .css, .html) to a pool of "static" web servers (running Lighttpd).
  1. # HTTP web cluster
  2. frontend cluster_http
  3. bind :80
  4. mode http
  5. option forwardfor
  6. acl content_php path_end .php
  7. use_backend dynamic_cluster_http if content_php
  8. default_backend static_cluster_http
  9.  
  10. # Static cluster serving every file EXCEPT those ending with .php
  11. backend static_cluster_http
  12. mode http
  13. option forwardfor
  14. balance source
  15. option httpclose
  16. option httpchk HEAD / HTTP/1.0
  17. server staticweb1 192.168.0.100:80 weight 1 check inter 1000 rise 5 fall 1
  18. server staticweb2 192.168.0.101:80 weight 1 check inter 1000 rise 5 fall 1
  19.  
  20. # Dynamic cluster serving files ending with .php
  21. backend dynamic_cluster_http
  22. mode http
  23. option forwardfor
  24. balance source
  25. option httpclose
  26. option httpchk HEAD / HTTP/1.0
  27. server dynweb1 192.168.0.102:80 weight 1 check inter 1000 rise 5 fall 1
  28. server dynweb2 192.168.0.103:80 weight 1 check inter 1000 rise 5 fall 1

以上是关于Haproxy通过acl';s实现不同后端的负载平衡web集群的主要内容,如果未能解决你的问题,请参考以下文章

使用HAPROXY的ACL实现基于文件后缀名的动态和静态资源分离

HAProxy中的ACL与自定义错误页面

HAproxy指南之haproxy实现应用动静分离(案例篇)

HAProxy配置为代理与负载均衡器之实践

使用HAProxy的ACL实现基于文件后缀名的动静分离

haproxy+openresty实现反向代理和ip透传