我想配置PostgreSQL只接受来自指定IP的连接。它不应该接受任何其他IP的请求。配置PostgreSQL只为LOCALHOST或指定的ip +端口工作
14
A
回答
13
下的pg_hba.conf允许本地和指定的IP有权限登录, 但拒绝别人。
# 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
4
检查PostgreSQL数据文件夹中的pg_hba.conf文件。这是客户端身份验证配置文件。
# TYPE DATABASE USER ADDRESS METHOD
host testdb testuser 192.168.1.1 md5
local testdb all md5
添加上述的pg_hba.conf文件
+1
请注意,PostgreSQL仍然会通过它在'postgresql.conf'中通过'listen_addresses'绑定的任何接口接受到它的端口的TCP套接字连接,但它不会让它们进行身份验证。如果你想防止即使是TCP握手,你也需要使用'iptables'。 – 2012-08-01 06:59:44
9
最简单的方法是,让PostgreSQL只localhost
传入连接听。 postgresql.conf
中的相关参数是listen_addresses
。文件是here。
相关问题
- 1. 将Localhost更改为带端口的IP
- 2. 只有端口80为网站工作
- 3. 在Google OAuth 2.0中为“localhost”重定向网址配置自定义端口
- 4. 指定--host1为localhost与端口8983在autobench
- 5. start-dfs.sh - 不工作 - localhost:坏端口'localhost'(Hadoop 2.7.2)
- 6. 如何使用配置为ng e2e指定端口和主机
- 7. 为什么在localhost这只是工作
- 8. 为url_指定端口
- 9. 为BlazeDS配置端口
- 10. postgresql:为什么在运行psql时必须指定-h localhost?
- 11. HTTPS端口不工作的2083端口
- 12. 如何指定端口号与IP注册服务器为gcm
- 13. 独立的Apache Spark - 作为从IP和端口放置什么?
- 14. 端口配置
- 15. 尽管被设置为特定IP,socket.io引用localhost
- 16. 在特定端口上的Localhost网站
- 17. 在NetTcpBinding上指定客户端端口(和IP)
- 18. 设置指定IP从搬运工,compose.yml
- 19. C#TCP/IP自定义IP和端口
- 20. 何处在VS代码中指定localhost端口
- 21. 主机localhost,端口1433的TCP/IP连接失败
- 22. 如何配置tomcat 5.5将localhost更改为ip地址
- 23. Selenium Grid2端口不能只在端口4444上工作
- 24. Apache上的特定端口配置
- 25. 配置nginx为不同的端口
- 26. 用于android模拟器的UDP端口转发; “adb转发udp:端口udp:端口”和telnet localhost adb_port不工作
- 27. MAMP端口配置
- 28. 如何从eclipse运行配置中指定appengine devserver端口?
- 29. 虚拟主机不在xmapp中工作(使用不同的端口为localhost:7777)
- 30. 在Visual Studio中为C#.NET指定Localhost端口异步/等待请求
PG的版本? OS?你的意思是只有localhost吗?或者“只接受来自一个非本地IP地址的连接”? – 2012-08-01 07:00:04