# haproxy 설치하기
apt-get update
apt-get install haproxy
# haproxy.cfg 수정하기
/etc/haproxy/haproxy.cfg
- 기본
global
# log setting
log /dev/log local0
log /dev/log local1 notice
chroot /var/lib/haproxy
stats socket /run/haproxy/admin.sock mode 660 level admin expose-fd listeners
stats timeout 30s
user haproxy
group haproxy
daemon
# Default SSL material locations
ca-base /etc/ssl/certs
crt-base /etc/ssl/private
# See: https://ssl-config.mozilla.org/#server=haproxy&server-version=2.0.3&config=intermediate
ssl-default-bind-ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384
ssl-default-bind-ciphersuites TLS_AES_128_GCM_SHA256:TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256
ssl-default-bind-options ssl-min-ver TLSv1.2 no-tls-tickets
defaults
log global
mode http
option httplog
option dontlognull
timeout connect 5000
timeout client 50000
timeout server 50000
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
- 수정
global
# log setting
log /dev/log local0
log /dev/log local1 notice
chroot /var/lib/haproxy
stats socket /run/haproxy/admin.sock mode 660 level admin expose-fd listeners
stats timeout 30s
user haproxy
group haproxy
daemon
# Default SSL material locations
ca-base /etc/ssl/certs
crt-base /etc/ssl/private
# See: https://ssl-config.mozilla.org/#server=haproxy&server-version=2.0.3&config=intermediate
ssl-default-bind-ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384
ssl-default-bind-ciphersuites TLS_AES_128_GCM_SHA256:TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256
ssl-default-bind-options ssl-min-ver TLSv1.2 no-tls-tickets
defaults
log global
mode http
option httplog
option dontlognull
timeout connect 5000
timeout client 50000
timeout server 50000
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 LOADBALANCER-01
# 들어오는 포트 지정
bind 192.168.0.209:80
mode http
default_backend WEBSERVERS-01
backend WEBSERVERS-01
# 로드밸런싱 옵션 - roundrobin : 번갈아 가면서 서버에 연결시킴
balance roundrobin
# http 서버 체크
option httpchk
http-check expect status 200
# 뒤에 check 파라메터가 있어야 해당 서버가 문제가 있으면 다시 그 서버로 리다이렉트 안함
server web1 49.247.18.211:8080 check
## server web2 192.168.0.185:8080 check
# backup 파라메터backup 으로 구성 될 경우 backup이 아닌 서버로 연결 된뒤 해당서버가 down시 backup으로 설정된 서버로 연결
server web2 192.168.0.209:8081 check backup
# 서비스 다시시작
service haproxy restart
# 서비스 종료
service haproxy stop
## 참고
www.haproxy.com/blog/the-four-essential-sections-of-an-haproxy-configuration/
반응형
'프로그래밍 > 웹서버 프로그래밍' 카테고리의 다른 글
리눅스 방화벽 설정 (0) | 2021.01.19 |
---|---|
Apache에서 사용하는 포트 번호를 변경하기 (0) | 2021.01.18 |
아파치 명령어 (0) | 2021.01.18 |
웹서버란? (0) | 2021.01.04 |
tomcat 실행 명령어 (0) | 2020.12.29 |