Willy Tarreau | 85270da | 2007-01-02 00:59:39 +0100 | [diff] [blame] | 1 | # |
Willy Tarreau | 677457e | 2015-10-13 15:38:46 +0200 | [diff] [blame] | 2 | # 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 Tarreau | 85270da | 2007-01-02 00:59:39 +0100 | [diff] [blame] | 4 | # |
| 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 Tarreau | 677457e | 2015-10-13 15:38:46 +0200 | [diff] [blame] | 7 | # starting with /admin/stats deliver the stats page. |
Willy Tarreau | 85270da | 2007-01-02 00:59:39 +0100 | [diff] [blame] | 8 | # |
| 9 | |
| 10 | global |
| 11 | maxconn 10000 |
Willy Tarreau | 677457e | 2015-10-13 15:38:46 +0200 | [diff] [blame] | 12 | stats socket /var/run/haproxy.stat mode 600 level admin |
Willy Tarreau | 85270da | 2007-01-02 00:59:39 +0100 | [diff] [blame] | 13 | log 127.0.0.1 local0 |
| 14 | uid 200 |
| 15 | gid 200 |
| 16 | chroot /var/empty |
| 17 | daemon |
| 18 | |
Willy Tarreau | 85270da | 2007-01-02 00:59:39 +0100 | [diff] [blame] | 19 | # The public 'www' address in the DMZ |
| 20 | frontend public |
Willy Tarreau | 677457e | 2015-10-13 15:38:46 +0200 | [diff] [blame] | 21 | bind 192.168.1.10:80 name clear |
| 22 | #bind 192.168.1.10:443 ssl crt /etc/haproxy/haproxy.pem |
Willy Tarreau | 85270da | 2007-01-02 00:59:39 +0100 | [diff] [blame] | 23 | mode http |
Willy Tarreau | 677457e | 2015-10-13 15:38:46 +0200 | [diff] [blame] | 24 | log global |
| 25 | option httplog |
Willy Tarreau | 85270da | 2007-01-02 00:59:39 +0100 | [diff] [blame] | 26 | option dontlognull |
Willy Tarreau | 677457e | 2015-10-13 15:38:46 +0200 | [diff] [blame] | 27 | monitor-uri /monitoruri |
| 28 | maxconn 8000 |
| 29 | timeout client 30s |
Willy Tarreau | 85270da | 2007-01-02 00:59:39 +0100 | [diff] [blame] | 30 | |
Willy Tarreau | 677457e | 2015-10-13 15:38:46 +0200 | [diff] [blame] | 31 | 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 Tarreau | 85270da | 2007-01-02 00:59:39 +0100 | [diff] [blame] | 35 | |
| 36 | # The static backend backend for 'Host: img', /img and /css. |
| 37 | backend static |
Willy Tarreau | 677457e | 2015-10-13 15:38:46 +0200 | [diff] [blame] | 38 | 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 Tarreau | 85270da | 2007-01-02 00:59:39 +0100 | [diff] [blame] | 48 | |
Willy Tarreau | 677457e | 2015-10-13 15:38:46 +0200 | [diff] [blame] | 49 | # the application servers go here |
Willy Tarreau | 85270da | 2007-01-02 00:59:39 +0100 | [diff] [blame] | 50 | backend dynamic |
Willy Tarreau | 85270da | 2007-01-02 00:59:39 +0100 | [diff] [blame] | 51 | mode http |
Willy Tarreau | 85270da | 2007-01-02 00:59:39 +0100 | [diff] [blame] | 52 | balance roundrobin |
Willy Tarreau | 677457e | 2015-10-13 15:38:46 +0200 | [diff] [blame] | 53 | 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 Tarreau | 85270da | 2007-01-02 00:59:39 +0100 | [diff] [blame] | 65 | |