Php webapp无法通过网络访问PostgreSQL数据库
我在这里运行有点愚蠢,因为我在通过网络访问数据库时遇到了问题 我已经在服务器A上部署了webapp,我想访问服务器B上的数据库。我已经在iptables中添加了必要的规则Php webapp无法通过网络访问PostgreSQL数据库,php,postgresql,Php,Postgresql,我在这里运行有点愚蠢,因为我在通过网络访问数据库时遇到了问题 我已经在服务器A上部署了webapp,我想访问服务器B上的数据库。我已经在iptables中添加了必要的规则 iptables -A INPUT -p tcp -s 0/0 --sport 1024:65535 -d 'client ip' --dport 5432 -m state --state NEW,ESTABLISHED -j ACCEPT iptables -A OUTPUT -p tcp -s 'client ip' -
iptables -A INPUT -p tcp -s 0/0 --sport 1024:65535 -d 'client ip' --dport 5432 -m state --state NEW,ESTABLISHED -j ACCEPT
iptables -A OUTPUT -p tcp -s 'client ip' --sport 5432 -d 0/0 --dport 1024:65535 -m state --state ESTABLISHED -j ACCEPT
我已在pg_hba.conf中添加了必要的权限
host all all 'client ip'/32 trust
hostssl all all 'client ip'/32 trust
我还可以通过CLI从服务器A连接到数据库
serverA:/etc/postgresql/9.4/main# psql -h 'server B Ip' -U postgres -d test
psql (9.4.5)
SSL connection (protocol: TLSv1.2, cipher: ECDHE-RSA-AES256-GCM-SHA384, bits: 256, compression: off)
Type "help" for help.
test=#
然而,我的webapp在尝试从服务器A访问数据库时抛出以下错误:
Message: pg_connect(): Unable to connect to PostgreSQL server:
FATAL: no pg_hba.conf entry for host "ServerA ip", user "postgres", database "test", SSL on
FATAL: no pg_hba.conf entry for host "ServerA ip", user "postgres", database "test", SSL off