Problem: Config Error Lepas Upgrade HAProxy
Lepas upgrade ke HAProxy 2.5.5, terus dapat error masa validate config:
[ALERT] (28348) : config : parsing [haproxy.cfg:25] : unknown keyword 'ca-base' in 'listen' section
[ALERT] (28348) : config : parsing [haproxy.cfg:26] : unknown keyword 'crt-base' in 'listen' section
[ALERT] (28348) : config : parsing [haproxy.cfg:30] : unknown keyword 'ssl-default-bind-ciphers' in 'listen' section
[ALERT] (28348) : config : Fatal errors found in configuration.
Keyword macam ca-base, crt-base, dan ssl-default-bind-ciphers dah tak valid dalam section listen untuk versi baru ni. Backup dulu config lama sebelum edit:
cp -p haproxy.cfg haproxy.cfg_20220327_OLDVERSION
Pasal Lua Support
HAProxy 2.5.5 support Lua untuk scripting lanjut, tapi kena build dengan flag USE_LUA=1. Versi Lua yang disokong: 5.3 ke atas.
Kalau nak build Lua sendiri:
cd /opt/lua-5.3.5
make linux
Kemudian masa build HAProxy, pass path tu:
make TARGET=generic \
USE_LUA=1 \
LUA_INC=/opt/lua-5.3.5/src \
LUA_LIB=/opt/lua-5.3.5/src
Masalahnya, kalau Lua yang ada dalam sistem tak boleh di-uninstall atau versi tak match, proses build akan fail. Jalan mudah: guna RPM builder dari GitHub.
Fix: Build RPM Guna GitHub Builder
Ada repo yang dah siapkan semua ni untuk CentOS/RHEL:
https://github.com/philyuchkoff/HAProxy-2-RPM-builder
Repo ni akan build HAProxy dengan Lua support sekali. Tak perlu urus dependency Lua secara manual.
git clone https://github.com/philyuchkoff/HAProxy-2-RPM-builder.git
cd HAProxy-2-RPM-builder
make
Output RPM akan ada dalam folder RPMS/. Install terus:
rpm -Uvh RPMS/x86_64/haproxy-*.rpm
Verify Installation
Semak versi dan pastikan Lua support ada:
/usr/sbin/haproxy -vv | grep -i lua
Pastikan output ada baris macam ni:
Built with Lua version : Lua 5.3.x
Validate config balik:
/usr/sbin/haproxy -c -f /etc/haproxy/haproxy.cfg
Semak Backend Status
Lepas HAProxy running, boleh tengok stats via socket atau stats page. Contoh output dari stats socket:
# pxname svname scur smax slim stot status
www-https FRONTEND 3 11 2000 28 OPEN
octoprint_backend BACKEND 0 0 200 0 UP
vpn_backend vpn 0 0 30 0 no check
Backend octoprint_backend status UP confirm HAProxy dah running betul selepas build baru.