|
| 1 | +#--------------------------------------------------------------------- |
| 2 | +# Example configuration for a possible web application. See the |
| 3 | +# full configuration options online. |
| 4 | +# |
| 5 | +# https://www.haproxy.org/download/3.2/doc/configuration.txt |
| 6 | +# https://cbonte.github.io/haproxy-dconv/3.2/configuration.html |
| 7 | +# |
| 8 | +#--------------------------------------------------------------------- |
| 9 | + |
| 10 | +#--------------------------------------------------------------------- |
| 11 | +# Global settings |
| 12 | +#--------------------------------------------------------------------- |
| 13 | +global |
| 14 | + # to have these messages end up in /var/log/haproxy.log you will |
| 15 | + # need to: |
| 16 | + # |
| 17 | + # 1) configure syslog to accept network log events. This is done |
| 18 | + # by adding the '-r' option to the SYSLOGD_OPTIONS in |
| 19 | + # /etc/sysconfig/syslog |
| 20 | + # |
| 21 | + # 2) configure local2 events to go to the /var/log/haproxy.log |
| 22 | + # file. A line like the following can be added to |
| 23 | + # /etc/sysconfig/syslog |
| 24 | + # |
| 25 | + # local2.* /var/log/haproxy.log |
| 26 | + # |
| 27 | + log 127.0.0.1 local2 |
| 28 | + |
| 29 | + chroot /var/lib/haproxy |
| 30 | + pidfile /var/run/haproxy.pid |
| 31 | + maxconn 4000 |
| 32 | + user haproxy |
| 33 | + group haproxy |
| 34 | + # daemon |
| 35 | + |
| 36 | + # turn on stats unix socket |
| 37 | + stats socket /var/lib/haproxy/stats |
| 38 | + |
| 39 | +#--------------------------------------------------------------------- |
| 40 | +# common defaults that all the 'listen' and 'backend' sections will |
| 41 | +# use if not designated in their block |
| 42 | +#--------------------------------------------------------------------- |
| 43 | +defaults |
| 44 | + mode http |
| 45 | + log global |
| 46 | + option httplog |
| 47 | + option dontlognull |
| 48 | + option http-server-close |
| 49 | + option forwardfor except 127.0.0.0/8 |
| 50 | + option redispatch |
| 51 | + retries 3 |
| 52 | + timeout http-request 10s |
| 53 | + timeout queue 1m |
| 54 | + timeout connect 10s |
| 55 | + timeout client 1m |
| 56 | + timeout server 1m |
| 57 | + timeout http-keep-alive 10s |
| 58 | + timeout check 10s |
| 59 | + maxconn 3000 |
| 60 | + |
| 61 | +#--------------------------------------------------------------------- |
| 62 | +# example how to define user and enable Data Plane API on tcp/5555 |
| 63 | +# more information: https://github.com/haproxytech/dataplaneapi and |
| 64 | +# https://www.haproxy.com/documentation/hapee/2-0r1/configuration/dataplaneapi/ |
| 65 | +#--------------------------------------------------------------------- |
| 66 | +# userlist haproxy-dataplaneapi |
| 67 | +# user admin insecure-password mypassword |
| 68 | +# |
| 69 | +# program api |
| 70 | +# command /usr/bin/dataplaneapi --host 0.0.0.0 --port 5555 --haproxy-bin /usr/sbin/haproxy --config-file /etc/haproxy/haproxy.cfg --reload-cmd "kill -SIGUSR2 1" --restart-cmd "kill -SIGUSR2 1" --reload-delay 5 --userlist haproxy-dataplaneapi |
| 71 | +# no option start-on-reload |
| 72 | + |
| 73 | +#--------------------------------------------------------------------- |
| 74 | +# main frontend which proxys to the backends |
| 75 | +#--------------------------------------------------------------------- |
| 76 | +frontend main |
| 77 | + bind *:80 |
| 78 | + # bind *:443 ssl # To be completed .... |
| 79 | + |
| 80 | + acl url_static path_beg -i /static /images /javascript /stylesheets |
| 81 | + acl url_static path_end -i .jpg .gif .png .css .js |
| 82 | + |
| 83 | + use_backend static if url_static |
| 84 | + default_backend app |
| 85 | + |
| 86 | +#--------------------------------------------------------------------- |
| 87 | +# static backend for serving up images, stylesheets and such |
| 88 | +#--------------------------------------------------------------------- |
| 89 | +backend static |
| 90 | + balance roundrobin |
| 91 | + server static1 127.0.0.1:4331 check |
| 92 | + server static2 127.0.0.1:4332 check |
| 93 | + |
| 94 | +#--------------------------------------------------------------------- |
| 95 | +# round robin balancing between the various backends |
| 96 | +#--------------------------------------------------------------------- |
| 97 | +backend app |
| 98 | + balance roundrobin |
| 99 | + server app1 127.0.0.1:5001 check |
| 100 | + server app2 127.0.0.1:5002 check |
| 101 | + server app3 127.0.0.1:5003 check |
| 102 | + server app4 127.0.0.1:5004 check |
0 commit comments