Return to Snippet

Revision: 16122
at July 27, 2009 11:11 by alexwilliams


Updated Code
# HTTP web cluster
frontend cluster_http
        bind    :80
        mode    http
        option  forwardfor
	acl content_php path_end .php
	use_backend dynamic_cluster_http if content_php
	default_backend static_cluster_http

# Static cluster serving every file EXCEPT those ending with .php
backend static_cluster_http
	mode 	http
        option  forwardfor
	balance source
        option  httpclose
        option  httpchk HEAD / HTTP/1.0
        server  staticweb1 192.168.0.100:80 weight 1 check inter 1000 rise 5 fall 1
        server  staticweb2 192.168.0.101:80 weight 1 check inter 1000 rise 5 fall 1

# Dynamic cluster serving files ending with .php
backend dynamic_cluster_http
        mode    http
        option  forwardfor
	balance source
        option  httpclose
        option  httpchk HEAD / HTTP/1.0
        server  dynweb1 192.168.0.102:80 weight 1 check inter 1000 rise 5 fall 1
        server  dynweb2 192.168.0.103:80 weight 1 check inter 1000 rise 5 fall 1

Revision: 16121
at July 27, 2009 11:08 by alexwilliams


Initial Code
# HTTP web cluster
frontend cluster_http
        bind    :80
        mode    http
        option  forwardfor
	acl content_php path_end .php
	use_backend dynamic_cluster_http if content_php
	default_backend static_cluster_http

# Static cluster service every page EXCEPT those ending with .php
backend static_cluster_http
	mode 	http
        option  forwardfor
	balance source
        option  httpclose
        option  httpchk HEAD / HTTP/1.0
        server  staticweb1 192.168.0.100:80 weight 1 check inter 1000 rise 5 fall 1
        server  staticweb2 192.168.0.101:80 weight 1 check inter 1000 rise 5 fall 1

# Dynamic cluster serving pages ending with .php
backend dynamic_cluster_http
        mode    http
        option  forwardfor
	balance source
        option  httpclose
        option  httpchk HEAD / HTTP/1.0
        server  dynweb1 192.168.0.102:80 weight 1 check inter 1000 rise 5 fall 1
        server  dynweb2 192.168.0.103:80 weight 1 check inter 1000 rise 5 fall 1

Initial URL


Initial Description
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).

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

Initial Tags
web

Initial Language
Other