[英]Alternatives for connecting MongoDB Atlas to Heroku Node.js app
I've been working on a simple website using node.js, express, and MongoDB, with Heroku as the platform.我一直在使用 node.js、express 和 MongoDB 开发一个简单的网站,以 Heroku 作为平台。 I had a lot of issues early on trying to connect to my MongoDB Atlas cluster, resulting in Heroku throwing request timeout errors.
我在尝试连接到我的 MongoDB Atlas 集群时遇到了很多问题,导致 Heroku 抛出请求超时错误。
After some googling, I surmised that the issue was that the IP addresses Heroku sends requests to my DB from weren't whitelisted in Atlas.经过一番谷歌搜索,我推测问题在于 IP 地址 Heroku 向我的数据库发送请求,这些请求未在 Atlas 中列入白名单。 The simplest solution at that point was to egregiously set up so that any IP is considered whitelisted.
那时最简单的解决方案是进行过分设置,以便将任何 IP 视为列入白名单。 Which actually works fine currently.
目前实际上工作正常。
My actual question comes down to the fact that whitelisting all IPs hardly seems like a professional way to go about doing things.我的实际问题归结为这样一个事实,即将所有 IP 列入白名单似乎不是 go 关于做事的专业方式。
What is a better solution?什么是更好的解决方案?
You should only allow those IPs from which your application will connect to MongoDB Atlas.您应该只允许您的应用程序将从其连接到 MongoDB Atlas 的那些 IP。 Allow
all IPs
is a bad practice and could make that MongoDB instance vulnerable.允许
all IPs
是一种不好的做法,并且可能会使 MongoDB 实例易受攻击。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.