osixia / docker-keepalived

Keepalived container image 🐳🌴
MIT License
395 stars 143 forks source link

keepalived inside the docker don't expose outside port when the network mode is host #57

Closed hcj11 closed 1 year ago

hcj11 commented 1 year ago

the virtual_server 192.168.113.133 1358 how to export the 1358 port host machine how to access.

the follow is keepalived file

global_defs { router_id 150 }

vrrp_instance VI_1 { state MASTER interface ens33 virtual_router_id 51 priority 100 advert_int 1 authentication { auth_type PASS auth_pass d0cker } virtual_ipaddress { 192.168.113.133 } }

virtual_server 192.168.113.133 1358 { delay_loop 3 lb_algo rr lb_kind DR persistence_timeout 50 protocol TCP

real_server 192.168.113.136 1358 {
    weight 1
    HTTP_GET {
        url {
          path /testurl/test
          digest 640205b7b0fc66c1ea91c463fac6334d
        }
        url {
          path /testurl2/test
          digest 640205b7b0fc66c1ea91c463fac6334d
        }
        url {
          path /testurl3/test
          digest 640205b7b0fc66c1ea91c463fac6334d
        }
        connect_timeout 30
        retry 3
        delay_before_retry 30
    }
}

real_server 192.168.113.137 1358 {
    weight 1
    HTTP_GET {
        url {
          path /testurl/test
          digest 640205b7b0fc66c1ea91c463fac6334d
        }
        url {
          path /testurl2/test
          digest 640205b7b0fc66c1ea91c463fac6334d
        }
        url {
          path /testurl3/test
          digest 640205b7b0fc66c1ea91c463fac6334d
        }
        connect_timeout 30
        retry 3
        delay_before_retry 30
    }
}

}