Index ¦ Archives

Compiling HAProxy from source on Fedora

Introduction

Since I always forget to write down all the dependencies and make options, here are my scribbly notes on how to compile HAProxy on Fedora 29.

Where to get the source

The GitHub URL is a mirror of the main repository and doesn't contain the other branches. It's handy and works fine if you're on the master branch: https://github.com/haproxy/haproxy

Other locations to get the source include:

https://www.haproxy.org/download/

http://git.haproxy.org/

Dependencies

dnf install pcre2 pcre2-devel lua lua-devel openssl-devel systemd-devel jemalloc jemalloc-devel git gcc zlib-devel make perl

Compiling

CFLAGS="-O2 -g -fno-strict-aliasing" ADDLIB="-ljemalloc" make -j4 -pipe TARGET=linux2628 USE_LINUX_TPROXY=1 USE_TFO=1 USE_ZLIB=1 USE_REGPARM=1 USE_PCRE2_STATIC=1 USE_PCRE2_JIT=1 USE_OPENSSL=1 USE_SYSTEMD=1 USE-NS=1 USE_LUA=1

Adjust the -j value to match the number of CPU cores on your system / how many you want to use for compiling. For the meaning of the values, see the INSTALL file located under the root of the haproxy git repository.

Installation

make install

Unless you configure a different prefix, this will install haproxy to /usr/local/sbin/haproxy. For the init scripts, and SELinux module support see the contrib folder. Personally I find both to be overkill, as Fedora provides a haproxy policy that is suitable if you follow the rules, and I use a simplified systemd service file.

Pitfalls

The options might not be ideal, this is more of a "Christmas packet" type-build (for CI/CD). For production use, you will want to tweak this further. Don't stick this in a Dockerfile and expect it to work flawlessly!

© Bruno Henc. Built using Pelican. Theme by Giulio Fidente on github.