I have a PgBouncer installed on the same host with postgres server and I have several scenarios for it:
- Monitoring(
pgwatch2) should connect withpeerauthentication to thepostgres(for example) database viaPgBouncer - External client connection should also be able connect to the database postgres via
PgBouncer(withhostauthentication method)
I can't understand how to properly configure PgBouncer to follow the rules:
- If the connection to
PgBounceris done via socket, it should proceed withpeerauthentication to the postgres server - If the connection uses the
hostauthentication method,PgBouncershould also connect to postgres server with the correspondinghostmethod
My current configuration is as follows, but it doesn't choose socket or localhost properly(sometimes it fails):
[databases]
* = host=localhost port=5432
* = host=/tmp port=5432
I added two different rules to fix my issues, but it doesn't seem to work as expected.
I think that you can't distinguish pools based on the incoming connection type. You could create a fake database entry, and then direct it to the real database in the config:
But in this case the peer authentication would be coming from the owner of the pgbouncer process, not from the owner of the monitoring client.