Created
October 4, 2017 06:14
-
-
Save franzramadhan/2eb692586f17e5609a9e4b34fdae5e08 to your computer and use it in GitHub Desktop.
HAProxy and Keepalived Configuration for resilient infrastructure
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
global | |
log 127.0.0.1 local2 info | |
chroot /var/lib/haproxy | |
pidfile /var/run/haproxy.pid | |
maxconn 1024 | |
user haproxy | |
group haproxy | |
daemon | |
defaults | |
mode http | |
option forwardfor | |
option http-server-close | |
log global | |
option httplog | |
timeout connect 10s | |
timeout client 30s | |
timeout server 30s | |
frontend web_servers_in | |
bind 10.32.6.167:80 | |
mode http | |
reqadd X-Forwarded-Proto:\ http | |
default_backend web_servers | |
option forwardfor | |
backend web_servers | |
mode http | |
balance roundrobin | |
server web-02 10.32.6.168:80 check #web2.moi.ams | |
server web-03 10.32.6.169:80 check #web3.moi.ams | |
frontend app_servers_in | |
bind 10.32.6.154:8080 | |
mode http | |
option forwardfor | |
option httplog | |
timeout http-request 1440000 | |
timeout client 1440000 | |
default_backend app_servers | |
backend app_servers | |
mode http | |
balance source | |
stick match src | |
stick-table type ip size 1m expire 30m | |
cookie SERVERID rewrite | |
server app2 10.32.6.151:8080 cookie moi-app2 check inter 2000 rise 2 fall 5 weight 1 | |
server app3 10.32.6.196:8080 cookie moi-app3 check inter 2000 rise 2 fall 5 weight 1 | |
timeout server 1440000 | |
#frontend db_servers_in | |
# bind 10.32.6.166:3306 | |
# mode tcp | |
# default_backend galera_cluster | |
#backend galera_cluster | |
# mode tcp | |
# balance roundrobin | |
# option httpchk | |
# server db1 10.32.6.164:3306 check port 9200 inter 5000 weight 1 | |
# server db2 10.32.6.165:3306 check port 9200 inter 5000 weight 1 | |
listen stats :1936 | |
mode http | |
stats enable | |
stats auth admin:1rstwap | |
stats hide-version | |
stats show-node | |
stats refresh 30s | |
stats uri /haproxy?stats |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
global_defs { | |
notification_email { | |
alert@moi.ams | |
} | |
notification_email_from lb1@moi.ams | |
smtp_server 127.0.0.1 | |
smpt_connect_timeout 30 | |
lvs_id LB1 | |
} | |
vrrp_script chk_haproxy { | |
script "/usr/bin/kill -0 haproxy" | |
interval 2 | |
weight 2 | |
timeout 2 | |
fall 2 | |
rise 2 | |
} | |
vrrp_script chk_maxscale { | |
script "/usr/bin/kill -0 maxscale" | |
interval 2 | |
weight 2 | |
timeout 2 | |
fall 2 | |
rise 2 | |
} | |
vrrp_instance WEB { | |
state MASTER | |
interface eth0 | |
virtual_router_id 51 | |
priority 101 #change based on priority and weight | |
advert_int 1 | |
authentication { | |
auth_type PASS | |
auth_pass 1111 | |
} | |
virtual_ipaddress { | |
10.32.6.167 dev eth0 | |
} | |
track_script { | |
chk_haproxy | |
} | |
} | |
#vrrp_instance DB { | |
# state MASTER | |
# interface eth0 | |
# virtual_router_id 61 | |
# priority 101 | |
# advert_int 1 | |
# authentication { | |
# auth_type PASS | |
# auth_pass 1111 | |
# } | |
#virtual_ipaddress { | |
# 10.32.6.166 dev eth0 | |
#} | |
#track_script { | |
# chk_maxscale | |
#} | |
#} | |
vrrp_instance APP { | |
state MASTER | |
interface eth0 | |
virtual_router_id 71 | |
priority 101 | |
advert_int 1 | |
authentication { | |
auth_type PASS | |
auth_pass 1111 | |
} | |
virtual_ipaddress { | |
10.32.6.154 dev eth0 | |
} | |
track_script { | |
chk_haproxy | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment