hapostgres / pg_auto_failover

Postgres extension and service for automated failover and high-availability
Other
1.07k stars 113 forks source link

pg_hba.conf file - how to add a line to the generated one? #882

Closed mohammad0omar closed 2 years ago

mohammad0omar commented 2 years ago

Hello, we are using pg_auto_failover in a docker-compose file, hence we want the database to accept external connections.

We need to modify the HBA configuration by adding this line as an example: "host all all 0.0.0.0/0 trust"

in another word we want the cluster to listen to all the addresses, how we can do this in pg_auto_failover??

This is an example from my docker-compose:

  node3:
    build:
          context: ./
          dockerfile: Dockerfile
    environment:
      PGDATA: /tmp/pgaf
      PG_AUTOCTL_DEBUG: 1
    command: [
    "pg_autoctl", "create", "postgres",
    "--ssl-self-signed",
    "--auth", "trust",
    "--pg-hba-lan",
    "--username", "ad",
    "--hostname","node3",
    "--dbname", "analytics",
    "--monitor", "postgresql://autoctl_node@monitor/pg_auto_failover",
    "--run"]
    expose:
      - 5432
DimCitus commented 2 years ago

The HBA file is only edited so far as to allow nodes known to pg_auto_failover to connect to each other. When it comes to connecting your application, then it's up to you to edit the HBA file. See https://pg-auto-failover.readthedocs.io/en/master/security.html#postgres-hba-rules.