Proper remote access control management in PostgreSQL

Posted on

Question :

I want to create environment that allows the limited number of machines connect to my database server.
For debugging needs all IP address have the remote access to PostgreSQL server

listen_addresses = '*'
host all all md5

I want to limit access. What is the canonical way to do that?
I though of using proxy server to connect from local machines to PostgreSQL server, but I’ll appreciate other ideas.

Answer :

Just change pg_hba.conf from

host all all md5

to rules you need. Columns are :
type (leave host),
access method.
For example, if you need to allow only and to connect any database using any username:

host all all md5
host all all md5
host all all reject

service postgresql reload
(or smt like that, depending on your system) to apply changes.

Leave a Reply

Your email address will not be published. Required fields are marked *