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
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.