Installing HAProxy 1.8 on CentOS6 (With SSL Support)

Haproxy version 1.8 is not available via yum for CentOS 6 so must be compiled manually. Follow the below to do this:

  • Firstly, install pre-requisits
sudo yum install gcc pcre-static pcre-devel openssl-devel -y
  • Download and extract Haproxy 1.8
tar zxfv haproxy-1.8.14.tar.gz
cd haproxy-1.8.14
  • Make and install
make TARGET=linux2628 USE_OPENSSL=1
make install
  • Create directories required by Haproxy (Create additional as required by your config)
sudo mkdir -p /etc/haproxy
sudo mkdir -p /var/lib/haproxy 
sudo touch /var/lib/haproxy/stats
  • Create a symbolic link so haproxy commands can be run as your user
sudo ln -s /usr/local/sbin/haproxy /usr/sbin/haproxy
  • Create a new haproxy user for the service to run as:
sudo useradd -r haproxy
  • Create the Haproxy service and update the BIN directory:
cp examples/haproxy.init /etc/init.d/haproxy
sudo chmod 755 /etc/init.d/haproxy
### Update BIN= line as follows: BIN=/usr/local/sbin/$BASENAME
  • Create your haproxy.cfg file (Base templates can be found online or copied from another server you are replacing if applicable)
  • Start the Haproxy service and set it to run on startup
service haproxy start
chkconfig haproxy on
  • Open ports in iptables as appropriate (80,443,8080?)
  • Restart the server and confirm service starts
service haproxy status

Any comments or questions? Get in touch here or Email me at [email protected]