Skip to content

Instantly share code, notes, and snippets.

@coleca
Created November 18, 2018 14:33
Show Gist options
  • Save coleca/7ff6b70c6d9c654f286109fca2e69c25 to your computer and use it in GitHub Desktop.
Save coleca/7ff6b70c6d9c654f286109fca2e69c25 to your computer and use it in GitHub Desktop.
#!/bin/bash
##
## Script: Installs a HA PROXY server for RDS on Debian Linux
##
## Run the script as ./install_rds_proxy.sh <DNS NAME OF RDS INSTANCE>
##
SERVER=${1:-usawssdb01.c1jinrprkxs4.us-east-2.rds.amazonaws.com}
apt-get update
apt-get install -y haproxy
echo "ENABLED=1" >>/etc/default/haproxy
cat << 'EOF' >/etc/haproxy/haproxy.cfg
global
log /dev/log local0
log /dev/log local1 notice
chroot /var/lib/haproxy
maxconn 4000
user haproxy
group haproxy
daemon
stats socket /var/lib/haproxy/stats mode 777
listen MSSQL 0.0.0.0:1433
timeout connect 10s
timeout client 1m
timeout server 1m
mode tcp
EOF
echo " server singleMSSQL ${SERVER}:1433" >> /etc/haproxy/haproxy.cfg
service haproxy restart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment