加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

postgresql – Vapor Framework:使用SSL配置postgres连接

发布时间:2020-12-13 15:51:53 所属栏目:百科 来源:网络整理
导读:我正在尝试连接到我的Heroku PostgreSQL数据库但是我有以下错误: cannotEstablishConnection("FATAL: no pg_hba.conf entry for host "37.167.93.189",user "clpnkpyttmdtyq",database "d3h6147v73mgtu",SSL offn") 我知道Heroku postgres数据库需要
我正在尝试连接到我的Heroku PostgreSQL数据库但是我有以下错误:

cannotEstablishConnection("FATAL:  no pg_hba.conf entry for host "37.167.93.189",user "clpnkpyttmdtyq",database "d3h6147v73mgtu",SSL offn")

我知道Heroku postgres数据库需要使用SSL连接,但我不知道如何在我的Droplet对象上配置连接.

这是我的postgresql.json配置文件:

{
    "host": "ec2-54-163-224-108.compute-1.amazonaws.com","user": "clpnkpyttmdtyq","password": "99201aa07c48e18e7bdf210937857b85bee37cd8d8cb904381b1ddff934c7a4f","database": "d3h6147v73mgtu","port": 5432
}

也许有ssl参数我不知道?

我如何添加VaporPostgresSQLProvider:

let drop = Droplet()

// Tell the droplet to use our SQL provider service
try drop.addProvider(VaporPostgreSQL.Provider.self)

有任何想法吗 ?

当我尝试使用我的本地postgres数据库时,它可以工作,因为它不需要ssl连接.

解决方法

这是一个让我个人付出很多代价的过程,这个解决方案适合我,试试这个

在文件Config>秘密> postgresql.json添加此配置(用于本地或远程,如果此文件不存在,请创建此)

{
   "host": "127.0.0.1","user": "your_user_pc","password": "","database": "your_user_pc","port": 5432
}

用户可以从终端获取它

$cd ~

在您的文件Procfile(位于您的项目上,通过finder显示)编辑并添加此代码

web: App --env=production --workdir="./"
web: App --env=production --workdir=./ --config:servers.default.port=$PORT --config:postgresql.url=$DATABASE_URL

现在你可以重新启动你的应用程序到heroku,你应该考虑从heroku正确配置服务器及其所有凭据和来自Heroku界面的Postgresql附加组件

注意:不要忘记你做的每一个改变,运行“蒸汽构建”或“蒸汽构建 – 清洁”

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读