만약 직접 구성 필요 시 문의해주세요~
현재 세팅된 VM
memory 4gb processors
ssh openssh-server 연결됨
sudo apt updat
sudo apt install -y haproxy 진행됨.
/etc/haproxy/haproxy.cfg (sudo vi /etc/haproxy/haproxy.cfg 조회 권장)
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
daemon
defaults
log global
mode http
option httplog
option dontlognull
timeout connect 5000
timeout client 50000
timeout server 50000
# Blue 버전 백엔드
backend be_blue
balance roundrobin
option httpchk GET /healthz
http-check expect status 200
# TODO: Swarm 서비스 IP/Port로 변경 필요
server blue1 10.147.21.10:8080 check inter 2s fall 3 rise 2
server blue2 10.147.21.12:8080 check inter 2s fall 3 rise 2
# Green 버전 백엔드
backend be_green
balance roundrobin
option httpchk GET /healthz
http-check expect status 200
# TODO: Swarm 서비스 IP/Port로 변경 필요
server green1 10.147.21.11:8080 check inter 2s fall 3 rise 2
server green2 10.147.21.13:8080 check inter 2s fall 3 rise 2
# HTTP 프론트엔드 (80번 포트)
frontend fe_http
bind *:80
default_backend be_blue
# HAProxy 통계 대시보드 (선택)
listen stats
bind *:8404
stats enable
stats uri /stats
stats auth admin:admin
/etc/haproxy/haproxy.cfg 작성 완료 구분 내용 Frontend bind *:80 (모든 IP에서 80번 포트로 수신) Backend - Blue 10.147.21.10:8080, 10.147.21.12:8080 (바뀌어도됨.) Backend - Green 10.147.21.11:8080, 10.147.21.13:8080 (바뀌어도됨.) Health Check GET /healthz (200 OK 확인) Stats Page http://10.147.20.20:8404/stats (ID/PW: admin/admin)
다음에 해야 할 일