Posted By

alexwilliams on 07/27/09


Tagged

web backend pool cluster acl haproxy


Versions (?)

Haproxy load-balanced web cluster with different backends through acl's


 / Published in: Other
 

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

Report this snippet  

You need to login to post a comment.