Postgresql 12 and HAProxy – asking for guidance

I have two PG12 servers and they are in a Master-Slave relationship (replication).

What I want to do is have a virtual ip and link it to the master DB server being replicated to the slave one. I want the slave DB server to promote to master when the formal master dies. (failover)

I am trying to use HAProxy but have no idea. Examples from Google have other applications involved. I tried to use repmgr but I keep getting error during installation. (FATAL: no pg_hba.conf entry for host "__IP__", user "__USER__", database "__DB__", SSL off)

Can anyone please give me an advice or guide me with an example?