如何获取正在访问MongoDB数据库的IP地址?
我需要将数据库保护到仅在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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先,确保您的防火墙会阻止所有IP之外的IP外部,除了您的应用服务器的IP,并允许访问端口
27017
上的数据库服务器。编辑您的
/etc/mongod.conf
文件。确保这些行出现在
#网络接口
下面,您可以通过下载MongoDB桌面客户端来测试您的设置在端口
27017
上。要访问日志文件以查看哪些IP访问您的数据库,请再次查看您的
/etc/mongod.conf
文件,并查找##在哪里编写日志记录数据
。这将是/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
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 port27017
.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: