Skip to content

Instantly share code, notes, and snippets.

@gavsmi
Last active February 29, 2016 06:03
Show Gist options
  • Save gavsmi/9a415ee9923d95981a8d to your computer and use it in GitHub Desktop.
Save gavsmi/9a415ee9923d95981a8d to your computer and use it in GitHub Desktop.
HAProxy install script
#!/bin/bash
# so 'add-apt-repository' works
sudo apt-get -y install python-software-properties
# add apt sources
sudo add-apt-repository ppa:vbernat/haproxy-1.5
# update apt
sudo apt-get update
# install pacakge
sudo apt-get -y install haproxy
# enable haproxy
sudo cat > /etc/default/haproxy << EOF
ENABLED=1
EOF
# configure rsyslog
sudo cat > /etc/rsyslog.d/49-haproxy.conf << EOF
\$ModLoad imudp
\$UDPServerAddress 127.0.0.1
\$UDPServerRun 514
local0.* -/var/log/haproxy.log
& ~
EOF
# restart rsyslog
sudo restart rsyslog
# download haproxy config file
cd /etc/haproxy
sudo wget https://gist.githubusercontent.com/gavsmi/53baa8ead642e682a0fb/raw/fadd39742280912946dfdd37d19f14884e6829fd/haproxy.cfg
# generate SSL cert
openssl req -x509 -nodes -days 730 -newkey rsa:2048 -keyout /tmp/mykey.key -out /tmp/mycert.crt -subj "/C=US/ST= /L= /O=Qmatic/OU= /CN= /emailAddress= "
cat /tmp/mycert.crt /tmp/mykey.key > /tmp/mycert.pem
cp /tmp/mycert.pem /etc/haproxy/mycert.pem
# restart haproxy
sudo service haproxy restart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment