RockyLinux 9 ๋ฒ์ ์์ HAProxy+QUIC ์กฐํฉ์ ์ฌ์ฉํ์ฌ ๊ตฌ์ฑํ๋ ๋ฐฉ๋ฒ์ ๋ํด์ ์ค๋ช ํ๋ค.
HAProxy๋ C ์ธ์ด๋ก ๊ฐ๋ฐ๋ TCP ๋ฐ HTTP ๊ธฐ๋ฐ ์ ํ๋ฆฌ์ผ์ด์ ์ ์ํด ๊ณ ๊ฐ์ฉ์ฑ ๋ก๋๋ฐธ๋ฐ์์ ๋ฆฌ๋ฒ์ค ํ๋ก์๋ฅผ ์ ๊ณตํ๋ ์คํ์์ค ์ํํธ์จ์ด๋ค.
TCP ๋ฐ HTTP ์ ํ๋ฆฌ์ผ์ด์
์ ๋ก๋ ๋ฐธ๋ฐ์ฑํ๊ณ ๊ณ ๊ฐ์ฉ์ฑ์ ์ ๊ณตํ๋๋ฐ ์ฃผ๋ก ์ฌ์ฉ๋๋ฉฐ ๋ก๋๋ฐธ๋ฐ์ฑ์ ์ฌ๋ฌ ์๋ฒ ์ฌ์ด์ ํธ๋ํฝ์ ๋ถ์ฐํ์ฌ ์๋ฒ์ ์ฑ๋ฅ์ ํฅ์์ํค๊ณ ๊ฐ์ฉ์ฑ์ ๋์ด๋ ๊ธฐ์ ์ด๋ค.
์ฌ๋ฌ ์๋ฒ๋ก ๋ค์ด์ค๋ ์์ฒญ์ ๋ถ์ฐํ์ฌ ๋ถํ๋ฅผ ๊ณต์ ํ๊ฒ ๋ถ๋ฐฐํ๊ณ , ๊ฐ ์๋ฒ์ ์ํ๋ฅผ ๋ชจ๋ํฐ๋งํ๋ฉฐ ๋ฌธ์ ๊ฐ ์๋ ์๋ฒ๋ฅผ ์ ์ธ์ํด์ผ๋ก์จ ์ ๋ขฐ์ฑ์ ๋์ผ์ ์๋ค.
๋ํ, ํ๋ก์ ์๋ฒ๋ก ์ฌ์ฉ๋ ์ ์์ด ํด๋ผ์ด์ธํธ์ ์๋ฒ ๊ฐ์ ํต์ ์ ์ค๊ฐํ๋ ์ญํ ์ ์ํํ ์ ์์ด์, ๋ณด์, ๋ก๊น , SSL ์ข ๋จ ๊ฐ์ ๋ฑ ๋ค์ํ ๊ธฐ๋ฅ์ ์ ๊ณตํ ์ ์๋ค.
๋์ ์ฑ๋ฅ๊ณผ ์์ ์ฑ, ์ ์ฐ์ฑ์ ์ ๊ณตํ๋ฉฐ, HTTP/1.1, HTTP/2, HTTP/3, TCP, SSL ๋ฑ ๋ค์ํ ํ๋กํ ์ฝ์ ์ง์ํ๋ค.
์ฃผ๋ก ์น ์ ํ๋ฆฌ์ผ์ด์
๋ฐ ๋ง์ดํฌ๋ก์๋น์ค ์ํคํ
์ฒ(MicroService Architecture, MSA)์์ ์ฌ์ฉ๋๋ฉฐ, ๋๊ท๋ชจ ์น ์ฌ์ดํธ ๋ฐ ์ ํ๋ฆฌ์ผ์ด์
์์ ๋ง์ด ์ฌ์ฉ๋๋ค.
MSA์์ ์ฌ์ฉ๋๋ ๊ฒฝ์ฐ๋ก๋ RedHat OpenShift์ Ingress Controller์์ ๊ธฐ๋ณธ์ผ๋ก ์ฌ์ฉ๋๊ณ ์์ผ๋ฉฐ,
์ค์ ๋ก ๋ณธ์ธ์ ํ์
์์ OpenShift ์์ง๋์ด๋ก ์ฌ์ง ์ค์ด๊ณ , ์ฑ๋ฅ ํ
์คํธ์ ์ฌ๋ฌ ์๋๋ฆฌ์ค์์ ๋๊ท๋ชจ ํธ๋ํฝ์ ์ ์ฒ๋ฆฌํ๋ ๊ฒ์ ํ์ธ ํ๋ค.
QUIC (Quick UDP Internet Connections)๋ ์น ํ๋กํ ์ฝ์ ํ๋๋ก์, Google์ด YouTube, Gmail ๋ฑ์์ ์ฌ์ฉํ๊ธฐ ์ํด ๊ฐ๋ฐ๋์๋ค.
๊ธฐ์กด์ TCP(Transmission Control Protocol)๋ฅผ ๋์ฒดํ๊ณ ์ ์ค๊ณ๋์์ผ๋ฉฐ, OSI 7 ๊ณ์ธต์ Layer 4 ์ ์ก ๊ณ์ธต(Transport Layer)์์ ์๋ํ๋ UDP(User Datagram Protocol)๋ฅผ ๊ธฐ๋ฐ์ผ๋ก ํ๋ค.
QUIC๋ TCP์ ๋น๊ตํ์ฌ ์ฌ๋ฌ๊ฐ์ง ์ด์ ์ ์ ๊ณตํ๋๋ฐ, ์ผ๋ฐ์ ์ธ TCP ์ฐ๊ฒฐ์์ ๋ฐ์ํ๋ Handshake์ RTT(Round-Trip Time)์ ์ค์ฌ ๋น ๋ฅธ ์ฐ๊ฒฐ ์ค์ ์ ๊ฐ๋ฅํ๊ฒ ํ๋ค.
๊ทธ๋ฆฌ๊ณ , TCP์ ํผ์ก ์ ์ด(TCP Congestion Control)์ ์ฌ์ ์ก ๊ธฐ๋ฅ์ ๊ฐ์ ํ์ฌ ํจํท ์์ค ๋ฐ ์ง์ฐ์ ๊ฐ์์ํค๋ฉฐ, ์ฌ๋ฌ ๊ฐ์ ๋์ ์คํธ๋ฆผ์ ์ฌ์ฉํ์ฌ ๋ณ๋ ฌ๋ก ๋ฐ์ดํฐ๋ฅผ ์ ์กํ ์ ์์ด์,
์น ํ์ด์ง์ ๋ฆฌ์์ค๋ค์ ๋์์ ๋ค์ด๋ก๋ํ๊ณ ์ฒ๋ฆฌํ ์ ์๊ฒ ํ์ฌ, ๋์ฑ ๋น ๋ฅธ ์น ํ์ด์ง ๋ก๋ฉ ์๊ฐ์ ๋จ์ถ ์ํค๊ณ ๋คํธ์ํฌ ์ฐ๊ฒฐ์ ํจ์จ์ฑ์ ํฅ์์ํฌ ์ ์๋ค.
QUIC๋ ์ฃผ๋ก ์น ๋ธ๋ผ์ฐ์ ์ ์น ์๋ฒ ๊ฐ์ ํต์ ์์ ์ฌ์ฉ๋๋ฉฐ, HTTP/3(Hypertext Transfer Protocol version 3)์ ํจ๊ป ์ฌ์ฉ๋๋ค.
ํ์ฌ QUIC์ IETF(Internet Engineering Task Force)์์ 2021๋
5์์ ํ์คํ ๋ฐํํ์์ผ๋ฉฐ, ๋ง์ ์ธํฐ๋ท ๊ธฐ์
๋ค์ด QUIC๋ฅผ ์ง์ํ๊ณ ๋์
ํ๊ณ ์๋ค.
QUIC๋ UDP๋ฅผ ์ฌ์ฉํ๋ฏ๋ก TCP์ ๋น๊ตํ์ ๋ ๋ ๋ฎ์ ์ง์ฐ ์๊ฐ๊ณผ ๋ ๋์ ๋์ญํญ์ ์ ๊ณตํ๋ค.
์ด๋ ์น ํ์ด์ง์ ๋ก๋ฉ ์๋๋ฅผ ํฅ์์ํค๊ณ , ์ค์๊ฐ ํต์ ์ด ํ์ํ ์ ํ๋ฆฌ์ผ์ด์
์ ์ ํฉํ๋ค.
QUIC์ ๊ธฐ์กด์ TCP์ ๋ฌ๋ฆฌ ์ฐ๊ฒฐ ์ค์ ๋จ๊ณ๊ฐ ํ์ํ์ง ์๋ค.
์ด๋ ์น ํ์ด์ง ๋ก๋ฉ ์๊ฐ์ ๋จ์ถ์ํค๋ ๋ฐ ๋์์ด ๋๋ฉฐ, TCP HOL(Head-of-Line Blocking) ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ์ฌ ์ฌ๋ฌ ๊ฐ์ ์์ฒญ์ ๋ณ๋ ฌ๋ก ์ฒ๋ฆฌํ ์ ์๋ค.
QUIC๋ TLS(Transport Layer Security) ์ํธํ๋ฅผ ๊ธฐ๋ณธ์ ์ผ๋ก ์ง์ํ๊ณ , ๋ฐ์ดํฐ์ ๊ธฐ๋ฐ์ฑ๊ณผ ๋ฌด๊ฒฐ์ฑ์ ๋ณด์ฅํ๋ค.
QUIC๋ IP ์ฃผ์๊ฐ ๋ณ๊ฒฝ๋๋ ๊ฒฝ์ฐ์๋ ์ฐ๊ฒฐ์ ์ ์งํ ์ ์์ผ๋ฉฐ, ๋ชจ๋ฐ์ผ ์ฅ์น์ ๊ฐ์ด ๋คํธ์ํฌ ์ฐ๊ฒฐ์ด ๋ถ์์ ํ ํ๊ฒฝ์์ ์ ์ฉํ๋ค.
RFC 9000: https://datatracker.ietf.org/doc/html/rfc9000
RFC 9001: https://datatracker.ietf.org/doc/html/rfc9001
RFC 9002: https://datatracker.ietf.org/doc/html/rfc9002
RFC 9003: https://datatracker.ietf.org/doc/html/rfc9003
RockyLinux 9 ๊ธฐ๋ฐ์์ HAProxy๋ฅผ ์์ค ์ปดํ์ผ ๋ฐฉ๋ฒ์ ๋ํด์ ์ค๋ช ํ๋ค.
HAProxy์์ ์ฌ์ฉํ ์ฌ์ฉ์์ ๊ทธ๋ฃน์ ์์ฑํ๋ค.
[root@haproxy ~]# HAPROXY_UID=1000
[root@haproxy ~]# HAPROXY_GID=1000
[root@haproxy ~]# groupadd -g $HAPROXY_GID haproxy
[root@haproxy ~]# useradd -d $PREFIX_DIR -c "HAProxy User" -u $HAPROXY_UID -g $HAPROXY_GID -s /sbin/nologin haproxy
์์ค ์ปดํ์ผ์ ํ์ํ ํจํค์ง๋ฅผ ์ค์น ํ๋ค.
[root@haproxy ~]# dnf groupinstall 'Development Tools'
[root@haproxy ~]# dnf install epel-release
[root@haproxy ~]# dnf install systemd-devel git-core procps-ng perl-FindBin perl-IPC-Cmd perl-Pod-Html cmake make gcc g++ perl python
Go๋ 2007๋
์ ๊ฐ๋ฐ๋ ์คํ ์์ค ํ๋ก๊ทธ๋๋ฐ ์ธ์ด๋ค.
Google์์ ๊ฐ๋ฐํ Go๋ ๊ฐ๊ฒฐํ๋ฉด์๋ ํจ์จ์ ์ธ ํ๋ก๊ทธ๋๋ฐ์ ์ํ ๋ชฉ์ ์ผ๋ก ์ค๊ณ๋์์ผ๋ฉฐ,
์ ์ ํ์
์ ์ปดํ์ผ ์ธ์ด๋ก, C์ ๊ฐ์ ์์คํ
์์ค์ ํ๋ก๊ทธ๋๋ฐ์ ์ง์ํ๋ฉด์๋ ์๋ ๋ฉ๋ชจ๋ฆฌ ๊ด๋ฆฌ ๋ฐ ๊ฐ๋น์ง ์ปฌ๋ ์
์ ์ ๊ณตํ๋ค.
BoringSSL ๋น๋์ Golang์ ํ์๋กํ๊ธฐ ๋๋ฌธ์ ๊ตฌ์ฑํ๋ค.
QuicSSL์ ์ฌ์ฉํ๋ ๊ฒฝ์ฐ Golang์ ๊ตณ์ด ๊ตฌ์ฑํ ํ์๋ ์๋ค.
[root@haproxy ~]# cd /opt
[root@haproxy ~]# curl -LO "https://go.dev/dl/go1.20.5.linux-amd64.tar.gz"
[root@haproxy ~]# tar xzvf go1.20.5.linux-amd64.tar.gz
[root@haproxy ~]# mkdir /opt/gopath
[root@haproxy ~]# vi /etc/profile
# GoLang
export GO_HOME=/opt/go
export GOPATH=/opt/gopath
export PATH=$PATH:$GO_HOME/bin
[root@haproxy ~]# source /etc/profile
QUIC๋ฅผ ์ฌ์ฉํ๊ธฐ ์ํด์๋ QUIC ์ ์ฉ SSL library๋ฅผ ์ฌ์ฉํด์ผ ํ๋ค.
library๋ก๋ ํฌ๊ฒ Google BoringSSL๊ณผ QuicTLS๊ฐ ์๋ค.
์ด ๋ฌธ์๋ ๋ผ์ด๋ธ๋ฌ๋ฆฌ์ ์ค๋ช ๊ณผ ํจ๊ป ์ํฉ์ ๋ง๊ฒ ์ ํํ์ฌ ์ฌ์ฉ ํ ์ ์๋๋ก 2๊ฐ์ง ๋ฐฉ์์ ์ ์ํ๊ฒ ๋ค.
BoringSSL์ Google์์ ๊ฐ๋ฐํ OpenSSL์ ํฌํฌ(Fork) ๋ฒ์ ์ผ๋ก, Google์ ๋ด๋ถ ํ๋ก์ ํธ๋ฅผ ์ํด ๊ฐ๋ฐ๋์์ง๋ง ์์ ์ฑ๊ณผ ๋ณด์์ฑ์ ์ค์ ์ ๋ ์ํธํ ์คํ์์ค ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ค.
OpenSSL์ ์ฝ๋ ๋ฒ ์ด์ค๋ฅผ ๊ธฐ๋ฐ์ผ๋ก ํ์ง๋ง ๊ฒฝ๋ํ ๋ฐ ๊ฐ์ํ๋ ๋ฒ์ ์ผ๋ก ๊ฐ๋ฐ๋์๋ค.
BoringSSL์ ๋ค์๊ณผ ๊ฐ์ ํน์ง์ ๊ฐ์ง๊ณ ์๋ค.
BoringSSL์ OpenSSL์ ๋นํด ์ฝ๋ ๋ฒ ์ด์ค๊ฐ ๊ฐ์ํ๋์ด ์์ผ๋ฉฐ, ์ฝ๋์ ๊ฐ๋ ์ฑ๊ณผ ์ ์ง ๋ณด์์ ์ฉ์ด์ฑ์ ํฅ์์ํจ๋ค.
BoringSSL์ OpenSSL์ ์ทจ์ฝ์ ์ ๋ณด์ํ๊ณ , ์๋ก์ด ๋ณด์ ๊ธฐ๋ฅ๊ณผ ์๊ณ ๋ฆฌ์ฆ์ ๊ตฌํํ์ฌ ๋ณด์ ๊ฐํ์ ์ด์ ์ ๋๊ณ ๊ฐ๋ฐ๋์๋ค.
BoringSSL์ ์ต์ ์ ์ํธํ ์๊ณ ๋ฆฌ์ฆ๊ณผ ํ๋กํ ์ฝ์ ์ง์ํ๋ฉฐ, TLS 1.3, ChaCha20-Poly1305, ECDSA(Elliptic Curve Digital Signature Algorithm) ๋ฑ์ ์ํธํ ๊ธฐ๋ฅ์ ์ ๊ณตํ๋ค.
BoringSSL์ ๊ฒฝ๋ํ๋ ๋์์ธ์ ํตํด ์์ ํฌ๊ธฐ์ ๋ฎ์ ๋ฉ๋ชจ๋ฆฌ ์ฌ์ฉ๋์ ๊ฐ์ง๊ณ ์์ด์ ๋ฆฌ์์ค ์ ์ฝ์ด ์๋ ์ฅ์น๋ ํ๊ฒฝ์์ ์ ์ฉํ๋ค.
์ค๋ช
์ ์ด์ฏค์์ ํ๊ณ , BoringSSL์ ์์ค ๋น๋๋ฅผ ์งํํ๋ค.
nproc ๋ช
๋ น์ด๋ ์์คํ
์ CPU ์ฝ์ด ๊ฐ์๋ฅผ ์ถ๋ ฅํ์ฌ GCC ๋น๋์ multi thread๋ก ์ปดํ์ผ์ ํ ์ ์๋๋ก ํ๋ค.
์์ ํ๊ฒ ์ปดํ์ผ ํ๊ณ ์ถ๋ค๋ฉด, -j $(nproc) ์ ๊ฑฐํ๊ณ make๋ง ์คํํ๋ฉด ๋๋ค.
[root@haproxy ~]# git clone https://github.com/google/boringssl.git /opt/boringssl
[root@haproxy ~]# cd /opt/boringssl
[root@haproxy ~]# mkdir build
[root@haproxy ~]# cd build
[root@haproxy ~]# cmake ..
[root@haproxy ~]# make -j $(nproc)
[root@haproxy ~]# make install
๋ง์ฝ, Container ํ๊ฒฝ์์ ๋น๋์ ์๋์ ๊ฐ์ด Threads๊ฐ ์๋ค๊ณ ๋์ค๋ ๊ฒฝ์ฐ๊ฐ ์๋ค.
Could NOT find Threads (missing: Threads_FOUND)
์ด ๊ฒฝ์ฐ์๋ CMakeLists.txt ํ์ผ์ ์๋ ๋ด์ฉ์ ์ถ๊ฐ ํ ๋น๋ํ๋ฉด ๋๋ค.
[root@haproxy ~]# vi CMakeLists.txt
set(CMAKE_THREAD_LIBS_INIT "-lpthread")
set(CMAKE_HAVE_THREADS_LIBRARY 1)
set(CMAKE_USE_WIN32_THREADS_INIT 0)
set(CMAKE_USE_PTHREADS_INIT 1)
set(THREADS_PREFER_PTHREAD_FLAG ON)
๋๋, sed ๋ช ๋ น์ด๋ก ํ์ค๋ก ์ฒ๋ฆฌํ ๋๋ ์๋์ ๊ฐ์ด ์ฌ์ฉํ๋ค.
[root@haproxy ~]# sed -i "1s/.*/set(CMAKE_THREAD_LIBS_INIT \"-lpthread\")\nset(CMAKE_HAVE_THREADS_LIBRARY 1)\nset(CMAKE_USE_WIN32_THREADS_INIT 0)\nset(CMAKE_USE_PTHREADS_INIT 1)\nset(THREADS_PREFER_PTHREAD_FLAG ON)\n\ncmake_minimum_required(VERSION 3.10)/g" CMakeLists.txt
QuicTLS๋ Google์ BoringSSL ํ๋ก์ ํธ์ ์ผ๋ถ๋ก ๊ฐ๋ฐ๋์๊ณ , BoringSSL์์ ๊ฐ์ ธ์จ ๊ธฐ์ ๊ณผ ์ฝ๋๋ฅผ ๊ธฐ๋ฐ์ผ๋ก QUIC ํ๋กํ ์ฝ์ TLS ์ ์ฉ์ ์ง์ํ์ฌ ๋ฐ์ดํฐ์ ๊ธฐ๋ฐ์ฑ, ๋ฌด๊ฒฐ์ฑ, ์ธ์ฆ์ ๋ณด์ฅํ๋ค.
๋ํ, ๋ค์ํ ์ธ์ด ๋ฐ ํ๋ ์์ํฌ์์ ์ฌ์ฉํ ์ ์๋ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ก ์ ๊ณต๋๋ฉฐ, ์ด๋ฅผ ํตํด QUIC ํ๋กํ ์ฝ์ ๊ตฌํํ๋ ์ ํ๋ฆฌ์ผ์ด์
์์ ๋ณด์ ์๊ตฌ ์ฌํญ์ ์ถฉ์กฑ์ํค๊ณ ์์ ํ ํต์ ์ ์ ๊ณตํ ์ ์๋ค.
QuicTLS์ ์ฃผ์ ํน์ง๊ณผ ๊ธฐ๋ฅ์ ๋ค์๊ณผ ๊ฐ๋ค.
QuicTLS๋ QUIC ํ๋กํ ์ฝ๊ณผ ๊ธด๋ฐํ๊ฒ ํตํฉ๋์ด ์์ ํ ๋ฐ์ดํฐ ์ ์ก์ ์ํ TLS ๊ธฐ๋ฅ์ ์ ๊ณตํ๋ฉฐ, QUIC์ ํน์ฑ์ ๋ง๊ฒ ์ฑ๋ฅ์ ์ต์ ํํ๊ณ , QUIC ์ฐ๊ฒฐ ์ค์ ๊ณผ ํธ๋์์ดํฌ๋ฅผ ์ง์ํ๋ค.
QuicTLS๋ TLS์ ๊ธฐ๋ฅ๊ณผ ๋ณด์ ํ๋กํ ์ฝ์ ์ ๊ณตํ์ฌ ๋ฐ์ดํฐ์ ๊ธฐ๋ฐ์ฑ, ๋ฌด๊ฒฐ์ฑ, ์ธ์ฆ ๋ณด์ฅ ๋ฐ ์ํธํ ์๊ณ ๋ฆฌ์ฆ, ๋์งํธ ์ธ์ฆ์, ํค ๊ตํ ๋ฑ์ ๊ธฐ๋ฅ์ ์ ๊ณตํ๋ค.
QuicTLS๋ BoringSSL์ ๊ธฐ์ ๊ณผ ์ต์ ํ๋ฅผ ํ์ฉํ์ฌ ์ฑ๋ฅ์ ํฅ์์ํค๋ฉฐ, QUIC์ ํน์ฑ๊ณผ ์๊ตฌ์ฌํญ์ ๋ง๊ฒ ๋์์ธ๋์ด, ๋น ๋ฅธ ์ฐ๊ฒฐ ์ค์ ๊ณผ ๋ฎ์ ์ง์ฐ์ ์ ๊ณตํ๋ค.
QuicTLS๋ ๋ค์ํ ํ๋ซํผ์์ ๋์ํ๋๋ก ์ค๊ณ๋์ด ์์ด์, Linux, Windows, macOS ๋ฑ ๋ค์ํ ์ด์์ฒด์ ์ ํธํ๋๋ค.
์ค๋ช
์ ์ด์ฏค์์ ํ๊ณ , QuicTLS์ ์์ค ๋น๋๋ฅผ ์งํํ๋ค.
nproc ๋ช
๋ น์ด๋ ์์คํ
์ CPU ์ฝ์ด ๊ฐ์๋ฅผ ์ถ๋ ฅํ์ฌ GCC ๋น๋์ multi thread๋ก ์ปดํ์ผ์ ํ ์ ์๋๋ก ํ๋ค.
์์ ํ๊ฒ ์ปดํ์ผ ํ๊ณ ์ถ๋ค๋ฉด, -j $(nproc) ์ ๊ฑฐํ๊ณ make๋ง ์คํํ๋ฉด ๋๋ค.
[root@haproxy ~]# git clone https://github.com/quictls/openssl.git /opt/quictls
[root@haproxy ~]# cd /opt/quictls
[root@haproxy ~]# ./Configure
[root@haproxy ~]# make -j $(nproc)
[root@haproxy ~]# make install
[root@haproxy ~]# curl -LO "https://www.haproxy.org/download/2.8/src/haproxy-2.8.0.tar.gz"
[root@haproxy ~]# tar xzvf haproxy-2.8.0.tar.gz
QUIC๋ฅผ ์ฌ์ฉํ๊ธฐ ์ํด Makefile์ ํด๋น ๋ณ์ ๋ด์ฉ์ ์ถ๊ฐํ๋ค.
(์ผ๋ถ ๋ณ์๋ค์ ์ฌ์ฉ์ ํ๊ฒฝ์ ๋ง๊ฒ ์ถ๊ฐํ๊ฑฐ๋ ์ ๊ฑฐํ๋ค.)
[root@haproxy ~]# cd /opt/haproxy-2.8.0
[root@haproxy ~]# vi Makefile
# Valid USE_* options are enumerated in the "use_opts" variable and are listed
# below. Most of them are automatically set by the TARGET, others have to be
# explicitly specified :
USE_EPOLL=1
USE_NETFILTER=1
USE_THREAD=1
USE_PTHREAD_PSHARED=1
USE_REGPARM=1
USE_TPROXY=1
USE_LINUX_TPROXY=1
USE_LIBCRYPT=1
USE_GETADDRINFO=1
USE_FUTEX=1
USE_ACCEPT4=1
USE_PRCTL=1
USE_ZLIB=1
USE_CPU_AFFINITY=1
USE_TFO=1
USE_OBSOLETE_LINKER=1
USE_THREAD_DUMP=1
USE_SYSTEMD=1
# QUIC ํ์ฑํ
USE_QUIC=1
USE_OPENSSL=1
# BoringSSL ๋๋ QuicTLS ์์น
# ๋ณ๋์ Prefix๋ฅผ ์ฌ์ฉํด์ ๋๋ ํ ๋ฆฌ ์์น๋ฅผ ์ง์ ํ ๊ฒฝ์ฐ ์ฌ์ฉํ๋ค.
#SSL_INC=/opt/quictls/include
#SSL_LIB=/opt/quictls/lib
#LDFLAGS="-Wl,-rpath,/opt/quictls/lib"
#### Installation options.
DESTDIR =
INSTALL = install
PREFIX = /opt/haproxy
SBINDIR = $(PREFIX)/sbin
MANDIR = $(PREFIX)/share/man
DOCDIR = $(PREFIX)/doc/haproxy
#### TARGET system
# Use TARGET=<target_name> to optimize for a specific target OS among the
# following list (use the default "generic" if uncertain) :
# linux-glibc, linux-glibc-legacy, linux-musl, solaris, freebsd, freebsd-glibc,
# dragonfly, openbsd, netbsd, cygwin, haiku, aix51, aix52, aix72-gcc, osx, generic,
# custom
TARGET = linux-glibc
#### TARGET CPU
# Use CPU=<cpu_name> to optimize for a particular CPU, among the following
# list :
# generic, native, i586, i686, ultrasparc, power8, power9, custom,
# a53, a72, armv81, armv8-auto
CPU = native
#### Architecture, used when not building for native architecture
# Use ARCH=<arch_name> to force build for a specific architecture. Known
# architectures will lead to "-m32" or "-m64" being added to CFLAGS and
# LDFLAGS. This can be required to build 32-bit binaries on 64-bit targets.
# Currently, only 32, 64, x86_64, i386, i486, i586 and i686 are understood.
ARCH = x86_64
[root@haproxy ~]# cd /opt/haproxy-2.8.0
[root@haproxy ~]# make -j $(nproc)
[root@haproxy ~]# make install
systemd๋ฅผ ์ฌ์ฉํ์ฌ ์๋น์ค๋ฅผ ๊ตฌ๋ ๋ฐ ์ค์ง๋ฅผ ํ ์ ์๋๋ก ์ค์ ํ๋ค.
[root@haproxy ~]# cp /opt/haproxy-2.8.0/admin/systemd/haproxy.service.in /lib/systemd/system/haproxy.service
์ฌ์ฉ์ ํ๊ฒฝ์ ๋ง๋๋ก ์ค์ ๊ฐ๋ค์ ์์ ํ๋ค.
[root@haproxy ~]# vi /lib/systemd/system/haproxy.service
[Unit]
Description=HAProxy Load Balancer
After=network-online.target
Wants=network-online.target
[Service]
EnvironmentFile=-/etc/default/haproxy
EnvironmentFile=-/etc/sysconfig/haproxy
Environment="CONFIG=/opt/haproxy/conf/haproxy.cfg" "PIDFILE=/opt/haproxy/haproxy.pid" "EXTRAOPTS=-S /opt/haproxy/stats"
ExecStart=@SBINDIR@/haproxy -Ws -f $CONFIG -p $PIDFILE $EXTRAOPTS
ExecReload=@SBINDIR@/haproxy -Ws -f $CONFIG -c -q $EXTRAOPTS
ExecReload=/bin/kill -USR2 $MAINPID
KillMode=mixed
Restart=always
SuccessExitStatus=143
Type=notify
# The following lines leverage SystemD's sandboxing options to provide
# defense in depth protection at the expense of restricting some flexibility
# in your setup (e.g. placement of your configuration files) or possibly
# reduced performance. See systemd.service(5) and systemd.exec(5) for further
# information.
# NoNewPrivileges=true
# ProtectHome=true
# If you want to use 'ProtectSystem=strict' you should whitelist the PIDFILE,
# any state files and any other files written using 'ReadWritePaths' or
# 'RuntimeDirectory'.
# ProtectSystem=true
# ProtectKernelTunables=true
# ProtectKernelModules=true
# ProtectControlGroups=true
# If your SystemD version supports them, you can add: @reboot, @swap, @sync
# SystemCallFilter=~@cpu-emulation @keyring @module @obsolete @raw-io
[Install]
WantedBy=multi-user.target
[root@haproxy ~]# systemctl enable haproxy
๊ฐ๋จํ HTTP, HTTPS ์ค์ ํ์ผ์ ์์ ๋ก ๋ง๋ ๋ค.
[root@haproxy ~]# vi /opt/haproxy/conf/haproxy.cfg
# Global settings
global
chroot /opt/haproxy
pidfile /opt/haproxy/haproxy.pid
maxconn 200000
# 800/KB
tune.maxrewrite 8192
tune.bufsize 32768
user haproxy
group haproxy
#daemon
log /dev/log local0 info
# turn on stats unix socket
stats socket /opt/haproxy/stats level admin expose-fd listeners
# SSL Cipher
tune.ssl.default-dh-param 2048
#ssl-default-bind-options no-sslv3
# generated 2023-06-10, Mozilla Guideline v5.7, HAProxy 2.8.0, OpenSSL 3.0.9+quic, intermediate configuration
# https://ssl-config.mozilla.org/#server=haproxy&version=2.8.0&config=intermediate&openssl=3.0.9+quic&guideline=5.7
# intermediate configuration
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:DHE-RSA-CHACHA20-POLY1305
ssl-default-bind-ciphersuites TLS_AES_128_GCM_SHA256:TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256
ssl-default-bind-options prefer-client-ciphers no-sslv3 no-tlsv10 no-tlsv11 no-tls-tickets
ssl-default-server-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:DHE-RSA-CHACHA20-POLY1305
ssl-default-server-ciphersuites TLS_AES_128_GCM_SHA256:TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256
ssl-default-server-options no-sslv3 no-tlsv10 no-tlsv11 no-tls-tickets
# mkdir /opt/haproxy/certs/
# curl https://ssl-config.mozilla.org/ffdhe2048.txt > /opt/haproxy/certs/dhparam
ssl-dh-param-file /opt/haproxy/certs/dhparam
# Multi-thread mode
nbthread 4
#cpu-map auto:1/1-4 0-3
# Multi-process mode
cpu-map 1 0
cpu-map 2 1
cpu-map 3 2
cpu-map 4 3
# HAProxy Status
#stats bind-process 4
defaults
mode http
log global
#option httplog clf
option dontlognull
option http-server-close
#option forwardfor except 10.88.0.0/16
option forwardfor
option redispatch
retries 3
timeout http-request 10s
timeout queue 1m
timeout connect 10s
timeout client 300s
timeout server 300s
timeout http-keep-alive 20s
timeout check 10s
maxconn 200000
#### HAProxy Status ####
listen stats
bind *:1936
mode http
stats enable
stats uri /
stats auth 'admin:admin'
#bind-process 4
#### HTTP ####
frontend default-http
# Service Port
bind *:80
# Balancer Type
balance roundrobin
# Syslog
log 127.0.0.1 local1
# Backend
default_backend default-http
backend default-http
# Balancer Type
balance roundrobin
# Backend Server
server nginx01 192.168.0.11:80 check inter 5s maxconn 200000
server nginx02 192.168.0.12:80 check inter 5s maxconn 200000
server nginx03 192.168.0.13:80 check inter 5s maxconn 200000
server nginx04 192.168.0.14:80 check inter 5s maxconn 200000
#### HTTPS ####
frontend default-https
# Service Port
bind :443 ssl crt /opt/haproxy/certs/ssl.pem alpn h2,http/1.1 allow-0rtt
bind quic4@:443 ssl crt /opt/haproxy/certs/ssl.pem alpn h3 allow-0rtt
# Balancer Type
balance roundrobin
# Syslog
log 127.0.0.1 local2
# Backend
default_backend default-https
# HTTP/3 (QUIC)
http-response set-header alt-svc "h3=\":443\"; ma=31536000"
# Enable HSTS(HTTP Strict Transport Security)
http-response set-header Strict-Transport-Security max-age=63072000
backend default-https
# Balancer Type
balance roundrobin
# Backend Server
server nginx01 192.168.0.11:443 ssl check inter 5s verify none maxconn 200000
server nginx02 192.168.0.12:443 ssl check inter 5s verify none maxconn 200000
server nginx03 192.168.0.13:443 ssl check inter 5s verify none maxconn 200000
server nginx04 192.168.0.14:443 ssl check inter 5s verify none maxconn 200000
[root@haproxy ~]# systemctl start haproxy
์์ ๋ด์ฉ์ ๊ธฐ๋ฐ์ผ๋ก HTTP/3๊ฐ ์ง์๋๊ณ ์๋์ง ๋งํฌ๋ฅผ ํตํด ํ์ธํ๋ค.
๋.