【发布时间】:2017-06-28 18:56:40
【问题描述】:
预测问题:我是否需要在 Heroku 上获得 SSL 支持才能在 Heroku 和 Atlas MongoDB Cloud 之间建立连接使用 SSL? (TSL/SSL 连接是requirement 来访问 Atlas MongoDB Cloud 服务)。
我正在尝试将我用 node.js 编写的 Heroku 应用程序连接到托管在 Atlas MongoDB Cloud 上的集群。
我当前的数据库托管在 mLab(作为 Heroku 插件),用于通过 mongoose 访问集群的 MongoDB URI 是(使用 xxx 省略机密信息):
MONGODB_URI="mongodb://xxx:xxx@xxx-a0.mlab.com:23266,xxx-a1.mlab.com:xxx/xxx?replicaSet=rs-xxx"
现在我已将数据从 mLab 迁移到 Atlas MongoDB Cloud,我目前正在使用 URI 访问集群:
MONGODB_URI="mongodb://xxx:xxx@cluster0-shard-xxx.mongodb.net:xxx,cluster0-shard-xxx.mongodb.net:xxx,cluster0-shard-xxx.mongodb.net:xxx/xxx?replicaSet=xxx&ssl=true&authSource=admin"
在我的机器上本地运行我的 Heroku 应用程序时,我可以毫无问题地访问数据库。我还可以使用 mongo shell 连接到集群。
但是,在 Heroku 中运行应用程序时,无法建立连接。在浏览器 JS 控制台中,我收到 503 服务不可用消息。在heroku中,我得到了错误:
no primary found in replica set
我知道 Atlas MongoDB Cloud 需要 SSL 连接,这与 mLab 不同。在我的本地机器上,我想使用自签名证书成功连接到集群。
我的问题是:我是否需要在 Heroku 中获得 SSL 支持才能访问在 Heroku 和 MongoDB Atlas 之间建立安全连接?或者 Heroku 中的 SSL 支持只需要客户端/Heroku 安全连接?
【问题讨论】:
标签: node.js mongodb ssl heroku mongoose