global_defs
{
enable_script_security
script_user root root
}



vrrp_script chk_myscript {
  script       "/etc/keepalived/track.sh"
  interval 5   # check every 2 seconds
  fall 2       # require 2 failures for KO
  rise 2       # require 2 successes for OK
} 


vrrp_instance VI_LB1 {
    state BACKUP
    interface eth1
    virtual_router_id 145
    priority 150
    unicast_src_ip ip_of_master_keepalived
    unicast_peer {
        ip_of_slave_keepalived
    }
    virtual_ipaddress {
	VIP1  dev eth1  # 
    	VIP2  dev eth2  # 
	VIP3  dev eth1  # 
	VIP4 dev eth2  # GATEWAY
    }


track_script {
    chk_myscript
  }


    track_interface {
        eth2           # Fault if down. eth2 is already monitored by VRRP.
    }
  
 nopreempt      # to avoid automatic switch  
 notify "/etc/keepalived/notifyapache.sh"
   



}

virtual_server_group PORT1812 {
        VIP2 1812
	VIP2 1812
}

virtual_server_group PORT1813 {
    VIP1 1813
    VIP1 1813
}




virtual_server VIP3 80 {
    delay_loop 10
    lb_algo rr
    lb_kind NAT
   # nat_mask 255.255.255.240
    #persistence_timeout 300
    #persistence_granularity 255.255.255.255
    protocol TCP

    real_server  IP_APACHE_1 8000 {
        weight 1
        HTTP_GET {
          url {
               path /alteon.html
               
                digest a7b8603f1c10e9229bea9e94c9645a53
              }
              connect_timeout 3
              nb_get_retry 3
              delay_before_retry 3
        }
    }


    real_server IP_APACHE_2 8000 {
        weight 1
        HTTP_GET {
          url {
               path /alteon.html
               
                digest a7b8603f1c10e9229bea9e94c9645a53
              }
              connect_timeout 3
              nb_get_retry 3
              delay_before_retry 3
        }
    }
}



virtual_server group PORT1812 {
    delay_loop 10
    lb_algo rr 
    lb_kind NAT
    #persistence_timeout 100   # de-activate for Active/Active
    protocol UDP

    real_server IP_RADIUS_1 1812 {
        weight 1
        MISC_CHECK {
#          misc_path "/etc/keepalived/bespoke_healthcheck.sh healthcheck1_srv1"
	  misc_path "/opt/application/radcheck.sh IP_RADIUS_1 1812"
          misc_timeout 5
        }
    }
    real_server IP_RADIUS_2 1812 {
        weight 1
        MISC_CHECK {
#          misc_path "/etc/keepalived/bespoke_healthcheck.sh healthcheck1_srv2"
	  misc_path "/opt/application/radcheck.sh IP_RADIUS_2 1812"
          misc_timeout 5
        }
    }
}

virtual_server group PORT1813 {
    delay_loop 10
    lb_algo rr
    lb_kind NAT
    #persistence_timeout 100   # de-activate for Active/Active
    protocol UDP

    real_server  IP_RADIUS_1  1813 {
        weight 1
        HTTP_GET {
          url {
               path /healthcheck
               status_code 200
              }
              connect_port 80
              connect_timeout 3
              nb_get_retry 3
              delay_before_retry 3
        }
    }

    real_server IP_RADIUS_2 1813 {
        weight 1
        HTTP_GET {
          url {
               path /healthcheck
	       status_code 200
              }
              connect_port 80
              connect_timeout 3
              nb_get_retry 3
              delay_before_retry 3
        }
    }
}
