Skip to content

Instantly share code, notes, and snippets.

@uorat
Created May 29, 2016 08:33
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save uorat/00d683b74e0acd38f1bee13bb4a0bd2b to your computer and use it in GitHub Desktop.
Save uorat/00d683b74e0acd38f1bee13bb4a0bd2b to your computer and use it in GitHub Desktop.
HAProxy configuration sample with resolvers options
global
log 127.0.0.1 local2
chroot /var/lib/haproxy
pidfile /var/run/haproxy.pid
maxconn 4096
user haproxy
group haproxy
daemon
stats socket /var/lib/haproxy/stats
stats maxconn 1
stats timeout 120s
resolvers awsvpc
nameserver vpc 172.31.0.2:53
defaults
mode tcp
log global
retries 3
timeout connect 10s
timeout client 1m
timeout server 1m
timeout check 10s
maxconn 512
listen mysql
bind 127.0.0.1:3306
mode tcp
option mysql-check user haproxy
# balance method : [roundrobin, static-rr, leastconn, source]
balance roundrobin
# usage: server hostname IP:Port check inter 2000(msec) fall 2
server read01 read01.XXXXXXXXXXXX.ap-northeast-1.rds.amazonaws.com:3306 check port 3306 resolvers awsvpc inter 2000 fall 5
server read02 read02.XXXXXXXXXXXX.ap-northeast-1.rds.amazonaws.com:3306 check port 3306 resolvers awsvpc inter 2000 fall 5
server master master.XXXXXXXXXXXX.ap-northeast-1.rds.amazonaws.com:3306 check port 3306 resolvers awsvpc backup
@gandhiamarnadh
Copy link

is line 15 the ip address of read01.XXXXXXXXXXXX.ap-northeast-1.rds.amazonaws.com ?

@anshprat
Copy link

is line 15 the ip address of read01.XXXXXXXXXXXX.ap-northeast-1.rds.amazonaws.com ?

No. Thats the DNS server / resolver to be used.

@StephenKing
Copy link

I suggest to use 169.254.169.253 as DNS server address, as this is available everywhere in AWS.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment