blob: e54f9760edacaa1eeff397093a0b72a74ac30309 [file] [log] [blame]
Willy Tarreau85270da2007-01-02 00:59:39 +01001#
Willy Tarreau677457e2015-10-13 15:38:46 +02002# This is a sample configuration. It illustrates how to separate static objects
3# traffic from dynamic traffic, and how to dynamically regulate the server load.
Willy Tarreau85270da2007-01-02 00:59:39 +01004#
5# It listens on 192.168.1.10:80, and directs all requests for Host 'img' or
6# URIs starting with /img or /css to a dedicated group of servers. URIs
Willy Tarreau677457e2015-10-13 15:38:46 +02007# starting with /admin/stats deliver the stats page.
Willy Tarreau85270da2007-01-02 00:59:39 +01008#
9
10global
11 maxconn 10000
Willy Tarreau677457e2015-10-13 15:38:46 +020012 stats socket /var/run/haproxy.stat mode 600 level admin
Willy Tarreau85270da2007-01-02 00:59:39 +010013 log 127.0.0.1 local0
14 uid 200
15 gid 200
16 chroot /var/empty
17 daemon
18
Willy Tarreau85270da2007-01-02 00:59:39 +010019# The public 'www' address in the DMZ
20frontend public
Willy Tarreau677457e2015-10-13 15:38:46 +020021 bind 192.168.1.10:80 name clear
22 #bind 192.168.1.10:443 ssl crt /etc/haproxy/haproxy.pem
Willy Tarreau85270da2007-01-02 00:59:39 +010023 mode http
Willy Tarreau677457e2015-10-13 15:38:46 +020024 log global
25 option httplog
Willy Tarreau85270da2007-01-02 00:59:39 +010026 option dontlognull
Willy Tarreau677457e2015-10-13 15:38:46 +020027 monitor-uri /monitoruri
28 maxconn 8000
29 timeout client 30s
Willy Tarreau85270da2007-01-02 00:59:39 +010030
Willy Tarreau677457e2015-10-13 15:38:46 +020031 stats uri /admin/stats
32 use_backend static if { hdr_beg(host) -i img }
33 use_backend static if { path_beg /img /css }
34 default_backend dynamic
Willy Tarreau85270da2007-01-02 00:59:39 +010035
36# The static backend backend for 'Host: img', /img and /css.
37backend static
Willy Tarreau677457e2015-10-13 15:38:46 +020038 mode http
39 balance roundrobin
40 option prefer-last-server
41 retries 2
42 option redispatch
43 timeout connect 5s
44 timeout server 5s
45 option httpchk HEAD /favicon.ico
46 server statsrv1 192.168.1.8:80 check inter 1000
47 server statsrv2 192.168.1.9:80 check inter 1000
Willy Tarreau85270da2007-01-02 00:59:39 +010048
Willy Tarreau677457e2015-10-13 15:38:46 +020049# the application servers go here
Willy Tarreau85270da2007-01-02 00:59:39 +010050backend dynamic
Willy Tarreau85270da2007-01-02 00:59:39 +010051 mode http
Willy Tarreau85270da2007-01-02 00:59:39 +010052 balance roundrobin
Willy Tarreau677457e2015-10-13 15:38:46 +020053 retries 2
54 option redispatch
55 timeout connect 5s
56 timeout server 30s
57 timeout queue 30s
58 option httpchk HEAD /login.php
59 cookie DYNSRV insert indirect nocache
60 fullconn 4000 # the servers will be used at full load above this number of connections
61 server dynsrv1 192.168.1.1:80 minconn 50 maxconn 500 cookie s1 check inter 1000
62 server dynsrv2 192.168.1.2:80 minconn 50 maxconn 500 cookie s2 check inter 1000
63 server dynsrv3 192.168.1.3:80 minconn 50 maxconn 500 cookie s3 check inter 1000
64 server dynsrv4 192.168.1.4:80 minconn 50 maxconn 500 cookie s4 check inter 1000
Willy Tarreau85270da2007-01-02 00:59:39 +010065