Skip to content

Instantly share code, notes, and snippets.

@huberflores
Last active Dec 12, 2015
Embed
What would you like to do?
Installation and Configuration of HAProxy
/*
* author Huber Flores
*/
# Download latest version of HAProxy from http://haproxy.1wt.eu/#down
# version downloaded for this tutorial
# haproxy-1.4.15.tar.gz (wget http://haproxy.1wt.eu/download/1.4/src/haproxy-1.4.15.tar.gz)
$ tar -xvf haproxy-1.4.15.tar.gz
# Compile HAProxy
$ make TARGET=linux26 ARCH=native
# "haproxy" file is created
# Move to your preferable location
$ cp haproxy /usr/local/sbin ///usr/local/sbin is usually in $PATH, so haproxy will then be easy to run simply by typing "haproxy".
# haproxy.conf
# Create a configuration file in /etc/haproxy/haproxy.conf
$ nano /etc/haproxy/haproxy.conf
global
maxconn 4096
pidfile /var/run/haproxy.pid
daemon
defaults
mode http
retries 3
option redispatch
maxconn 2000
contimeout 5000
clitimeout 50000
srvtimeout 50000
listen DRAGONFLY 172.xxx.xxx.xxx:80
mode http
cookie DRAGONFLY insert
balance roundrobin
option httpclose
option forwardfor
stats enable
stats auth myuser:mypass
server Server1 172.xxx.xxx.xxx:8080 cookie DRAGONFLY_Server_01 check
server Server2 172.xxx.xxx.xxx:8080 cookie DRAGONFLY_Server_02 check
server ServerN 172.xxx.xxx.xxx:8080 cookie DRAGONFLY_Server_N check
Start HAProxy
haproxy -f /etc/haproxy/haproxy.conf
Statistics about HAProxy
http://yourserver/haproxy?stats
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment