192.168.0.1 (80 또는 443) 접속 시, 192.168.0.2 ~ 3으로 분기해주는 설정 예시입니다.
https(443)는 SSL 종단(termination) 처리하지 않고, backend 서버에게 맡깁니다.
이를 위해 http mode가 아닌 tcp mode 로 설정합니다.
필요 시, 인증서 설정을 추가하여 http mode 로 설정하면, 보다 세부적인 설정 및 모니터링이 가능합니다만,
여기서는 다루지 않습니다. (원래 사용자의 IP 확인, 접속 통계 확인 등)
# vi /etc/haproxy/haproxy.cfg
global
log /dev/log local0
pidfile /run/haproxy.pid
chroot /var/lib/haproxy
maxconn 20000
user haproxy
group haproxy
daemon
stats socket /var/run/haproxy.sock mode 600 level admin
defaults
log global
option dontlognull
timeout connect 5s
timeout client 50s
timeout server 50s
# Reverse proxy sample
frontend http_front
bind 192.168.0.1:80
option tcplog
mode tcp
default_backend http_back
backend http_back
mode tcp
balance source
server web01 192.168.0.2:80 check
server web02 192.168.0.3:80 check
frontend https_front
bind 192.168.0.1:443
option tcplog
mode tcp
default_backend https_back
backend https_back
mode tcp
balance source
option ssl-hello-chk
server web01 192.168.0.2:443 check
server web02 192.168.0.3:443 check