How To Install haproxy on CentOS 8

haproxy is HAProxy reverse proxy for high availability environments

Introduction

In this tutorial we learn how to install haproxy on CentOS 8.

What is haproxy

HAProxy is a TCP/HTTP reverse proxy which is particularly suited for high availability environments. Indeed, it can - route HTTP requests depending on statically assigned cookies - spread load among several servers while assuring server persistence through the use of HTTP cookies - switch to backup servers in the event a main one fails - accept connections to special ports dedicated to service monitoring - stop accepting connections without breaking existing ones - add, modify, and delete HTTP headers in both directions - block requests matching particular patterns - report detailed status to authenticated users from a URI intercepted from the application

We can use yum or dnf to install haproxy on CentOS 8. In this tutorial we discuss both methods but you only need to choose one of method to install haproxy.

Install haproxy on CentOS 8 Using dnf

Update yum database with dnf using the following command.

sudo dnf makecache --refresh

The output should look something like this:

CentOS Linux 8 - AppStream                                       43 kB/s | 4.3 kB     00:00    
CentOS Linux 8 - BaseOS                                          65 kB/s | 3.9 kB     00:00    
CentOS Linux 8 - ContinuousRelease                               43 kB/s | 3.0 kB     00:00    
CentOS Linux 8 - Extras                                          23 kB/s | 1.5 kB     00:00    
CentOS Linux 8 - FastTrack                                       40 kB/s | 3.0 kB     00:00    
CentOS Linux 8 - HighAvailability                                36 kB/s | 3.9 kB     00:00    
CentOS Linux 8 - Plus                                            24 kB/s | 1.5 kB     00:00    
CentOS Linux 8 - PowerTools                                      50 kB/s | 4.3 kB     00:00    
Extra Packages for Enterprise Linux Modular 8 - x86_64           13 kB/s | 9.2 kB     00:00    
Extra Packages for Enterprise Linux 8 - x86_64                   24 kB/s | 8.5 kB     00:00    
Metadata cache created.

After updating yum database, We can install haproxy using dnf by running the following command:

sudo dnf -y install haproxy

Install haproxy on CentOS 8 Using yum

Update yum database with yum using the following command.

sudo yum makecache --refresh

The output should look something like this:

CentOS Linux 8 - AppStream                                       43 kB/s | 4.3 kB     00:00    
CentOS Linux 8 - BaseOS                                          65 kB/s | 3.9 kB     00:00    
CentOS Linux 8 - ContinuousRelease                               43 kB/s | 3.0 kB     00:00    
CentOS Linux 8 - Extras                                          23 kB/s | 1.5 kB     00:00    
CentOS Linux 8 - FastTrack                                       40 kB/s | 3.0 kB     00:00    
CentOS Linux 8 - HighAvailability                                36 kB/s | 3.9 kB     00:00    
CentOS Linux 8 - Plus                                            24 kB/s | 1.5 kB     00:00    
CentOS Linux 8 - PowerTools                                      50 kB/s | 4.3 kB     00:00    
Extra Packages for Enterprise Linux Modular 8 - x86_64           13 kB/s | 9.2 kB     00:00    
Extra Packages for Enterprise Linux 8 - x86_64                   24 kB/s | 8.5 kB     00:00    
Metadata cache created.

After updating yum database, We can install haproxy using yum by running the following command:

sudo yum -y install haproxy

How To Uninstall haproxy on CentOS 8

To uninstall only the haproxy package we can use the following command:

sudo dnf remove haproxy

haproxy Package Contents on CentOS 8

/etc/haproxy
/etc/haproxy/haproxy.cfg
/etc/logrotate.d/haproxy
/etc/sysconfig/haproxy
/usr/bin/halog
/usr/bin/iprange
/usr/lib/.build-id
/usr/lib/.build-id/05
/usr/lib/.build-id/05/3e8866280b6206e36255a46f0ea1bb79705784
/usr/lib/.build-id/a1
/usr/lib/.build-id/a1/0bb61846c6f940fb88d7d3c250bb10f525a102
/usr/lib/.build-id/ab
/usr/lib/.build-id/ab/964c67b286c6f72430c820b0a7d30f88cb6b49
/usr/lib/systemd/system/haproxy.service
/usr/sbin/haproxy
/usr/share/doc/haproxy
/usr/share/doc/haproxy/51Degrees-device-detection.txt
/usr/share/doc/haproxy/CHANGELOG
/usr/share/doc/haproxy/DeviceAtlas-device-detection.txt
/usr/share/doc/haproxy/README
/usr/share/doc/haproxy/ROADMAP
/usr/share/doc/haproxy/SPOE.txt
/usr/share/doc/haproxy/VERSION
/usr/share/doc/haproxy/WURFL-device-detection.txt
/usr/share/doc/haproxy/acl-content-sw.cfg
/usr/share/doc/haproxy/acl.fig
/usr/share/doc/haproxy/architecture.txt
/usr/share/doc/haproxy/auth.cfg
/usr/share/doc/haproxy/close-options.txt
/usr/share/doc/haproxy/coding-style.txt
/usr/share/doc/haproxy/configuration.txt
/usr/share/doc/haproxy/content-sw-sample.cfg
/usr/share/doc/haproxy/cookie-options.txt
/usr/share/doc/haproxy/design-thoughts
/usr/share/doc/haproxy/design-thoughts/backends-v0.txt
/usr/share/doc/haproxy/design-thoughts/backends.txt
/usr/share/doc/haproxy/design-thoughts/be-fe-changes.txt
/usr/share/doc/haproxy/design-thoughts/binding-possibilities.txt
/usr/share/doc/haproxy/design-thoughts/buffer-redesign.txt
/usr/share/doc/haproxy/design-thoughts/buffers.fig
/usr/share/doc/haproxy/design-thoughts/config-language.txt
/usr/share/doc/haproxy/design-thoughts/connection-reuse.txt
/usr/share/doc/haproxy/design-thoughts/connection-sharing.txt
/usr/share/doc/haproxy/design-thoughts/dynamic-buffers.txt
/usr/share/doc/haproxy/design-thoughts/entities-v2.txt
/usr/share/doc/haproxy/design-thoughts/how-it-works.txt
/usr/share/doc/haproxy/design-thoughts/http2.txt
/usr/share/doc/haproxy/design-thoughts/http_load_time.url
/usr/share/doc/haproxy/design-thoughts/rate-shaping.txt
/usr/share/doc/haproxy/design-thoughts/sess_par_sec.txt
/usr/share/doc/haproxy/gpl.txt
/usr/share/doc/haproxy/haproxy.1
/usr/share/doc/haproxy/internals
/usr/share/doc/haproxy/internals/acl.txt
/usr/share/doc/haproxy/internals/body-parsing.txt
/usr/share/doc/haproxy/internals/buffer-operations.txt
/usr/share/doc/haproxy/internals/buffer-ops.fig
/usr/share/doc/haproxy/internals/connect-status.txt
/usr/share/doc/haproxy/internals/connection-header.txt
/usr/share/doc/haproxy/internals/connection-scale.txt
/usr/share/doc/haproxy/internals/entities-v2.txt
/usr/share/doc/haproxy/internals/entities.fig
/usr/share/doc/haproxy/internals/entities.pdf
/usr/share/doc/haproxy/internals/entities.svg
/usr/share/doc/haproxy/internals/entities.txt
/usr/share/doc/haproxy/internals/filters.txt
/usr/share/doc/haproxy/internals/hashing.txt
/usr/share/doc/haproxy/internals/header-parser-speed.txt
/usr/share/doc/haproxy/internals/header-tree.txt
/usr/share/doc/haproxy/internals/http-cookies.txt
/usr/share/doc/haproxy/internals/http-docs.txt
/usr/share/doc/haproxy/internals/http-parsing.txt
/usr/share/doc/haproxy/internals/list.fig
/usr/share/doc/haproxy/internals/listener-states.fig
/usr/share/doc/haproxy/internals/listener-states.png
/usr/share/doc/haproxy/internals/lua_socket.fig
/usr/share/doc/haproxy/internals/lua_socket.pdf
/usr/share/doc/haproxy/internals/naming.txt
/usr/share/doc/haproxy/internals/pattern.dia
/usr/share/doc/haproxy/internals/pattern.pdf
/usr/share/doc/haproxy/internals/polling-states.fig
/usr/share/doc/haproxy/internals/repartition-be-fe-fi.txt
/usr/share/doc/haproxy/internals/sequence.fig
/usr/share/doc/haproxy/internals/stats-v2.txt
/usr/share/doc/haproxy/internals/stream-sock-states.fig
/usr/share/doc/haproxy/intro.txt
/usr/share/doc/haproxy/lgpl.txt
/usr/share/doc/haproxy/linux-syn-cookies.txt
/usr/share/doc/haproxy/lua-api
/usr/share/doc/haproxy/lua-api/Makefile
/usr/share/doc/haproxy/lua-api/_static
/usr/share/doc/haproxy/lua-api/_static/channel.fig
/usr/share/doc/haproxy/lua-api/_static/channel.png
/usr/share/doc/haproxy/lua-api/conf.py
/usr/share/doc/haproxy/lua-api/index.rst
/usr/share/doc/haproxy/lua.txt
/usr/share/doc/haproxy/management.txt
/usr/share/doc/haproxy/netscaler-client-ip-insertion-protocol.txt
/usr/share/doc/haproxy/network-namespaces.txt
/usr/share/doc/haproxy/option-http_proxy.cfg
/usr/share/doc/haproxy/peers-v2.0.txt
/usr/share/doc/haproxy/peers.txt
/usr/share/doc/haproxy/proxy-protocol.txt
/usr/share/doc/haproxy/queuing.fig
/usr/share/doc/haproxy/regression-testing.txt
/usr/share/doc/haproxy/ssl.cfg
/usr/share/doc/haproxy/transparent_proxy.cfg
/usr/share/doc/haproxy/wurfl-example.cfg
/usr/share/haproxy
/usr/share/haproxy/400.http
/usr/share/haproxy/403.http
/usr/share/haproxy/408.http
/usr/share/haproxy/500.http
/usr/share/haproxy/502.http
/usr/share/haproxy/503.http
/usr/share/haproxy/504.http
/usr/share/haproxy/README
/usr/share/licenses/haproxy
/usr/share/licenses/haproxy/LICENSE
/usr/share/man/man1/halog.1.gz
/usr/share/man/man1/haproxy.1.gz
/var/lib/haproxy

References

Summary

In this tutorial we learn how to install haproxy on CentOS 8 using yum and dnf.