본문 바로가기

리눅스

[draft] 우분투에 HAProxy를 설치하는 방법

728x90

우분투에 최신 HAProxy를 설치하는 방법

공식 HAProxy PPA(Personal Package Archive)를 사용하면 됩니다. 우분투의 기본 패키지 관리자를 통해 제공되는 HAProxy 버전이 최신 버전이 아닐 수 있기 때문에 PPA를 추가하여 최신 버전을 설치하는 방법이 유용합니다.

haproxy_latest_release
haproxy_latest_release

패키지 리스트 업데이트

sudo apt-get update

필수 패키지 설치

sudo apt-get install -y --no-install-recommends software-properties-common

HAProxy PPA 추가

sudo add-apt-repository -y ppa:vbernat/haproxy-3.0

패키지 리스트 다시 업데이트

sudo apt-get update

설치될 HAProxy 버전 확인

sudo apt show haproxy
$ sudo apt show haproxy
Package: haproxy
Version: 3.0.2-1ppa1~jammy
Priority: optional
Section: net
Maintainer: Debian HAProxy Maintainers <team+haproxy@tracker.debian.org>
Installed-Size: 5,127 kB
Pre-Depends: dpkg (>= 1.17.14), init-system-helpers (>= 1.54~)
Depends: libc6 (>= 2.34), libcrypt1 (>= 1:4.1.0), libjemalloc2 (>= 2.1.1), liblua5.3-0, libopentracing-c-wrapper0 (>= 1.1.0), libpcre2-8-0 (>= 10.22), libssl3 (>= 3.0.0~~alpha1), adduser, lsb-base (>= 3.0-6)
Suggests: vim-haproxy, haproxy-doc
Download-Size: 2,251 kB
APT-Sources: https://ppa.launchpadcontent.net/vbernat/haproxy-3.0/ubuntu jammy/main amd64 Packages
Description: fast and reliable load balancing reverse proxy
 HAProxy is a TCP/HTTP reverse proxy which is particularly suited for high
 availability environments. It features connection persistence through HTTP
 cookies, load balancing, header addition, modification, deletion both ways. It
 has request blocking capabilities and provides interface to display server
 status.

N: There are 3 additional records. Please use the '-a' switch to see them.

사용 가능한 HAProxy 버전 확인 (설치 가능한 버전)

sudo apt-cache policy haproxy
$ apt-cache policy haproxy
haproxy:
  Installed: (none)
  Candidate: 3.0.2-1ppa1~jammy
  Version table:
     3.0.2-1ppa1~jammy 500
        500 https://ppa.launchpadcontent.net/vbernat/haproxy-3.0/ubuntu jammy/main amd64 Packages
     2.4.24-0ubuntu0.22.04.1 500
        500 http://kr.archive.ubuntu.com/ubuntu jammy-updates/main amd64 Packages
     2.4.22-0ubuntu0.22.04.3 500
        500 http://kr.archive.ubuntu.com/ubuntu jammy-security/main amd64 Packages
     2.4.14-1ubuntu1 500
        500 http://kr.archive.ubuntu.com/ubuntu jammy/main amd64 Packages

HAProxy 설치

sudo apt-get install -y haproxy=3.0.\*

설치 확인

haproxy -v
$ haproxy -v
HAProxy version 3.0.2-1ppa1~jammy 2024/06/14 - https://haproxy.org/
Status: long-term supported branch - will stop receiving fixes around Q2 2029.
Known bugs: http://www.haproxy.org/bugs/bugs-3.0.2.html
Running on: Linux 5.15.0-113-generic #123-Ubuntu SMP Mon Jun 10 08:16:17 UTC 2024 x86_64

서비스 시작 및 자동 시작 설정

sudo systemctl --now enable haproxy

HAProxy 설정 파일

sudo vim /etc/haproxy/haproxy.cfg
더보기

---

cat /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

        # 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

---

HAProxy 구성 체크

sudo haproxy -c -f /etc/haproxy/haproxy.cfg

설정 변경 후 서비스 재시작

sudo systemctl restart haproxy

서비스 상태 확인

sudo systemctl status haproxy --no-pager -l

 

우분투에 최신 HAProxy를 설치하고 구성할 수 있습니다.

 

참고URL

- Debian/Ubuntu HAProxy packages : https://haproxy.debian.net

 

728x90