如何获取正在访问MongoDB数据库的IP地址?

发布于 2025-02-12 16:13:27 字数 249 浏览 0 评论 0原文

我需要将数据库保护到仅在App Server(后端Node.js and Express.js)的访问请求

时,在白名单上列入App Server(Azure App Service Linux)时,它会断开并且无法连接。 我也尝试将Web服务器(Frontend React Azure App Service Windows)和它不起作用。 当白名单0.0.0.0起作用时,因此问题是,如果不是应用程序,则IP是用户的吗? 以及如何获取这些信息?

谢谢

i need to secure the database to only access request from app server ( backend node.js and express.js)

when whitelisting the ip address of app server(azure app service linux), it breaks and can not connect.
i tried to whitelist the web server(frontend react azure app service windows) as well and its not working.
when whitelist 0.0.0.0 it works, so the question is what ip is making the request if it is not the app or the web is it the user?
and how to obtain that information?

thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

怀里藏娇 2025-02-19 16:13:28

首先,确保您的防火墙会阻止所有IP之外的IP外部,除了您的应用服务器的IP,并允许访问端口27017上的数据库服务器。

编辑您的/etc/mongod.conf文件。

确保这些行出现在#网络接口下面,

net:
  port: 27017
  bindIp: 0.0.0.0

您可以通过下载MongoDB桌面客户端来测试您的设置在端口27017上。

要访问日志文件以查看哪些IP访问您的数据库,请再次查看您的/etc/mongod.conf文件,并查找##在哪里编写日志记录数据。这将是/var/log/mongodb/mongod.log

您可以使用此命令将日志文件转移到终端:

sudo cat /var/log/mongodb/mongod.log

First, ensure that your firewall blocks all outside IPs except for the IP of your app server and allow access to your database server on port 27017.

Edit your /etc/mongod.conf file.

Ensure these lines appear below # network interfaces

net:
  port: 27017
  bindIp: 0.0.0.0

You can test your setup by downloading a MongoDB desktop client like Robo 3T and whitelisting your own home/office computer's IP address for your server's firewall on port 27017.

To access your log file to see which IPs are accessing your database, look again at your /etc/mongod.conf file and look for # where to write logging data. This will be something like /var/log/mongodb/mongod.log

You can dump your log file to the terminal with this command:

sudo cat /var/log/mongodb/mongod.log
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文