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

前端之家收集整理的这篇文章主要介绍了postgresql – Vapor Framework:使用SSL配置postgres连接前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在尝试连接到我的Heroku Postgresql数据库但是我有以下错误

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

我知道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附加组件

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

猜你在找的Postgre SQL相关文章