How it works...
HAProxy has a very powerful configuration syntax, which is backed by hundreds of parameters. While this makes it quite versatile, trying to write a configuration file from scratch would be extremely difficult. In our case, the number of parameters we need to set is actually fairly minimal.
We start by creating a simple role named haproxy_check so HAProxy can attempt to connect to PostgreSQL and verify the server is responding. HAProxy uses its own connection method that has some compatibility problems if no username is specified. PostgreSQL roles are not allowed to connect to any database by default, but are sufficient to pass a connectivity attempt. Once HAProxy has attempted to connect to PostgreSQL and has received an expected ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access