HAProxy에서 SSL 인증서를 적용하는 방법
SSL 인증서 및 개인 키 생성
mkdir -p /etc/ssl/ha_sangchul_krcd /etc/ssl/ha_sangchul_kropenssl req -newkey rsa:4096 \
-x509 \
-sha256 \
-days 3650 \
-nodes \
-out ha_sangchul_kr.crt \
-keyout ha_sangchul_kr.key \
-subj "/C=KR/ST=Seoul/L=Jongno-gu/O=SangChul Co., Ltd./OU=Infrastructure Team/CN=ha.sangchul.kr"openssl 명령어를 사용하여 인증서의 CN(Common Name) 및 유효 기간(Validity date)을 확인
openssl x509 -in /etc/ssl/ha_sangchul_kr/ha_sangchul_kr.crt -noout -subject -dates$ openssl x509 -in /etc/ssl/ha_sangchul_kr/ha_sangchul_kr.crt -noout -subject -dates
subject=C = KR, ST = Seoul, L = Jongno-gu, O = "SangChul Co., Ltd.", OU = Infrastructure Team, CN = ha.sangchul.kr
notBefore=Jan 29 04:11:25 2024 GMT
notAfter=Jan 26 04:11:25 2034 GMTSSL 인증서 파일 목록
$ ls -l
total 16
-rw-r--r-- 1 root     root     2114 Jan 29 04:11 ha_sangchul_kr.crt
-rw------- 1 root     root     3272 Jan 29 04:11 ha_sangchul_kr.keySSL 인증서 파일 통합(개인 키 + 서버 인증서)
cat ha_sangchul_kr.key ha_sangchul_kr.crt > unified_ha_sangchul_kr.pem$ ls -l | egrep unified
-rw-r--r-- 1 root root 5386 Jan 29 04:43 unified_ha_sangchul_kr.pemHAProxy 설정 파일 편집
vim /etc/haproxy/haproxy.cfg...
frontend https-in
    bind *:443 ssl crt /etc/ssl/ha_sangchul_kr/unified_ha_sangchul_kr.pem
    acl url_admin       path_beg       /admin
    use_backend bk_admin     if url_admin
    default_backend             bk_web
...구성 파일의 유효성을 검사
haproxy -c -f /etc/haproxy/haproxy.cfg -V$ haproxy -c -f /etc/haproxy/haproxy.cfg -V
Configuration file is validHAProxy 재시작
sudo systemctl restart haproxyOpenSSL을 사용하여 SSL 인증서에서 Subject와 유효 기간을 확인하는 방법
echo | openssl s_client -connect ha.sangchul.kr:443 2>/dev/null | openssl x509 -noout -subject -dates$ echo | openssl s_client -connect ha.sangchul.kr:443 2>/dev/null | openssl x509 -noout -subject -dates
subject=C = KR, ST = Seoul, L = Jongno-gu, O = "SangChul Co., Ltd.", OU = Infrastructure Team, CN = ha.sangchul.kr
notBefore=Jan 29 04:11:25 2024 GMT
notAfter=Jan 26 04:11:25 2034 GMT자체 서명된 SSL 인증서 사용
서버에 설치된 자체 서명된 SSL 인증서를 신뢰할 수 있도록 curl에게 알려줘야 합니다. 이를 위해 -k 또는 --insecure 옵션을 사용하여 curl이 SSL 인증서의 유효성을 검사하지 않도록 설정할 수 있습니다.
curl -sk https://ha.sangchul.kr | html2text$ curl -sk https://ha.sangchul.kr | html2text
****** Welcome to nginx! ******
node01 - 172.19.0.3
Thank you for using nginx.
'리눅스' 카테고리의 다른 글
| [draft] 우분투에서 MongoDB Community Edition을 설치하는 방법 (0) | 2025.10.31 | 
|---|---|
| [draft] Amazon Linux 2를 온프레미스 환경에서 VirtualBox 가상 머신으로 실행하는 방법 (0) | 2025.10.31 | 
| [draft] HAProxy 컴파일을 통해 설치하는 방법 (0) | 2025.10.31 | 
| [draft] HAProxy 로깅(haproxy logging) 설정하는 방법 (0) | 2025.10.31 | 
| [draft] CentOS 8 Stream 설치 (0) | 2025.10.31 | 
 
                  
                 
                  
                 
                  
                