将PostgreSQL配置为仅适用于LOCALHOST或指定的ip +端口 [英] Configure PostgreSQL to work for only LOCALHOST or specified ip + port
本文介绍了将PostgreSQL配置为仅适用于LOCALHOST或指定的ip +端口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想配置PostgreSQL只接受来自指定IP的连接。
I want to configure PostgreSQL to accept connections only from a specified IP. It should not accept requests from any other IP.
推荐答案
以下pg_hba.conf允许本地和指定的Ip具有特权登录,
但拒绝其他。
The following pg_hba.conf allows local and specified Ip have privilege login, but reject others。
# TYPE DATABASE USER ADDRESS METHOD
local all all trust
host testdb testuser 192.168.1.1/32 md5
host all all 0.0.0.0/0 reject
这篇关于将PostgreSQL配置为仅适用于LOCALHOST或指定的ip +端口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文