# HAProxy configuration showing using Basic Auth on Stats page
global
    log /dev/log local0
    log /dev/log local1 notice
    chroot /var/lib/haproxy
    stats socket /run/haproxy/admin.sock mode 660 level admin
    stats timeout 30s
    user haproxy
    group haproxy
    ca-base /etc/ssl/certs
    crt-base /etc/ssl/private
    ssl-default-bind-ciphers ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256
    ssl-default-bind-options no-sslv3
    description HAProxy Statistics Page

defaults
    log global
    timeout connect 5000
    timeout client  50000
    timeout server  50000
    mode http
    option httplog
    option dontlognull
    balance roundrobin
    errorfile 400 /etc/haproxy/errors/400.http
    errorfile 403 /etc/haproxy/errors/403.http
    errorfile 408 /etc/haproxy/errors/408.http
    errorfile 500 /etc/haproxy/errors/500.http
    errorfile 502 /etc/haproxy/errors/502.http
    errorfile 503 /etc/haproxy/errors/503.http
    errorfile 504 /etc/haproxy/errors/504.http

frontend fe_main
    bind :80
    bind :443 ssl crt mysite.pem
    http-request redirect scheme https unless ssl_fc
    default_backend webservers

backend webservers
    server web1 192.168.0.3:80 check maxconn 20
    server web2 192.168.0.4:80 check maxconn 20
    server web3 192.168.0.5:80 check maxconn 20
    server web4 192.168.0.6:80 check maxconn 20

listen stats
    bind :9999 ssl crt mycert.pem
    stats enable
    stats uri /report
    stats refresh 30s
    stats auth admin:password
    stats show-desc
    http-request deny unless { src 192.168.50.0/24 }