ha-proxy
L4, L7 계층에서 Reverce Proxy를 이용한 로드밸런서
Mode : http, tcp
log 127.0.0.1 lacal2
local2 : indice/shard
log level : debug(7) info(6) notice(5) warning(4) err(3) crit(2) alert(1) critical(0)
1. 설치
dnf install haproxy
apt install haproxy
2. haproxy 설정 삽입
vim /etc/haproxy/haproxy.cfg
frontend tired_fr
bind *:80
mode http
default_backend tired_bac
backend tired_bac
balance roundrobin
mode http
server s1 w1.tired.com check
server s2 w2.tired.com check
server s3 w3.tired.com check
server s4 w4.tired.com check
errorfile 503 /etc/haproxy/errors/503.http
3. haproxy 로깅
vim /etc/rsyslog.d/haproxy.conf
local2.* /var/log/haproxy_http.log
# 만약 local2 Index를 사용중일경우 /etc/haproxy/haproxy.cfg에서 수정
systemctl restart rsyslog haproxy
로그 정보 :
Dec 3 12:19:29 localhost haproxy[886911]: 172.16.13.19:33708 [03/Dec/2024:12:19:29.697] tired_fr tired_bac/s1 0/0/0/1/1 404 363 - - ---- 2/2/0/0/0 0/0 "GET /CSS/index.css HTTP/1.1"
Dec 3 12:19:29 localhost haproxy[886911]: 172.16.13.19:33702 [03/Dec/2024:12:19:29.755] tired_fr tired_bac/s2 0/0/1/0/1 200 211 - - ---- 2/2/0/0/0 0/0 "GET / HTTP/1.1"
Dec 3 12:19:29 localhost haproxy[886911]: 172.16.13.19:33702 [03/Dec/2024:12:19:29.896] tired_fr tired_bac/s3 0/0/0/1/1 200 1172 - - ---- 2/2/0/0/0 0/0 "GET / HTTP/1.1"
Dec 3 12:19:29 localhost haproxy[886911]: 172.16.13.19:33702 [03/Dec/2024:12:19:29.931] tired_fr tired_bac/s4 0/0/0/1/1 404 361 - - ---- 2/2/1/0/0 0/0 "GET /font_fi.css HTTP/1.1"
Dec 3 12:19:29 localhost haproxy[886911]: 172.16.13.19:33708 [03/Dec/2024:12:19:29.931] tired_fr tired_bac/s1 0/0/1/0/1 404 363 - - ---- 2/2/0/0/0 0/0 "GET /CSS/index.css HTTP/1.1"
Docs:
https://www.haproxy.com/documentation/haproxy-configuration-manual/latest/
4. Loadbalancing 트래픽 분석
listen status
bind :9997
stats enable
stats uri /
stats hide-version
stats refresh 5s
stats auth root:asd123!@
'네트워크 및 서버 > 서버' 카테고리의 다른 글
SSH 인증서 로그인 (0) | 2024.12.10 |
---|---|
비동기식 DB 백업(Mysql/Mariadb) (0) | 2024.12.04 |
Web Server 로드밸런싱 (0) | 2024.12.02 |
Clamav / Amavis (0) | 2024.11.25 |
Web(Apache) SSL 인증서 발급 및 적용 (0) | 2024.11.15 |