7d3267
#---------------------------------------------------------------------
7d3267
# Example configuration for a possible web application.  See the
7d3267
# full configuration options online.
7d3267
#
7d3267
#   http://haproxy.1wt.eu/download/1.4/doc/configuration.txt
7d3267
#
7d3267
#---------------------------------------------------------------------
7d3267
7d3267
#---------------------------------------------------------------------
7d3267
# Global settings
7d3267
#---------------------------------------------------------------------
7d3267
global
7d3267
    # to have these messages end up in /var/log/haproxy.log you will
7d3267
    # need to:
7d3267
    #
7d3267
    # 1) configure syslog to accept network log events.  This is done
7d3267
    #    by adding the '-r' option to the SYSLOGD_OPTIONS in
7d3267
    #    /etc/sysconfig/syslog
7d3267
    #
7d3267
    # 2) configure local2 events to go to the /var/log/haproxy.log
7d3267
    #   file. A line like the following can be added to
7d3267
    #   /etc/sysconfig/syslog
7d3267
    #
7d3267
    #    local2.*                       /var/log/haproxy.log
7d3267
    #
7d3267
    log         127.0.0.1 local2
7d3267
7d3267
    chroot      /var/lib/haproxy
7d3267
    pidfile     /var/run/haproxy.pid
7d3267
    maxconn     4000
7d3267
    user        haproxy
7d3267
    group       haproxy
7d3267
    daemon
7d3267
7d3267
    # turn on stats unix socket
7d3267
    stats socket /var/lib/haproxy/stats
7d3267
7d3267
#---------------------------------------------------------------------
7d3267
# common defaults that all the 'listen' and 'backend' sections will
7d3267
# use if not designated in their block
7d3267
#---------------------------------------------------------------------
7d3267
defaults
7d3267
    mode                    http
7d3267
    log                     global
7d3267
    option                  httplog
7d3267
    option                  dontlognull
7d3267
    option http-server-close
7d3267
    option forwardfor       except 127.0.0.0/8
7d3267
    option                  redispatch
7d3267
    retries                 3
7d3267
    timeout http-request    10s
7d3267
    timeout queue           1m
7d3267
    timeout connect         10s
7d3267
    timeout client          1m
7d3267
    timeout server          1m
7d3267
    timeout http-keep-alive 10s
7d3267
    timeout check           10s
7d3267
    maxconn                 3000
7d3267
7d3267
#---------------------------------------------------------------------
7d3267
# main frontend which proxys to the backends
7d3267
#---------------------------------------------------------------------
7d3267
frontend  main *:5000
7d3267
    acl url_static       path_beg       -i /static /images /javascript /stylesheets
7d3267
    acl url_static       path_end       -i .jpg .gif .png .css .js
7d3267
7d3267
    use_backend static          if url_static
7d3267
    default_backend             app
7d3267
7d3267
#---------------------------------------------------------------------
7d3267
# static backend for serving up images, stylesheets and such
7d3267
#---------------------------------------------------------------------
7d3267
backend static
7d3267
    balance     roundrobin
7d3267
    server      static 127.0.0.1:4331 check
7d3267
7d3267
#---------------------------------------------------------------------
7d3267
# round robin balancing between the various backends
7d3267
#---------------------------------------------------------------------
7d3267
backend app
7d3267
    balance     roundrobin
7d3267
    server  app1 127.0.0.1:5001 check
7d3267
    server  app2 127.0.0.1:5002 check
7d3267
    server  app3 127.0.0.1:5003 check
7d3267
    server  app4 127.0.0.1:5004 check
7d3267