Home > Software engineering >  Mask IP Address for MongoDB Connection String
Mask IP Address for MongoDB Connection String

Time:03-11

Summary

Hi I am Using a Linode Server Machine to Host a MongoDB Database, My Connection String Looks something like this:

mongodb://username:[email protected]:27017,129.547.965.154:27017,165.698.120.047/somedb?retryWrites=true&w=majority

Problem

Notice How this will expose the IP Address of the Machines as Well I can't find how to mask these IP addresses with another name like test.mongo.com or something.

Please Help in Getting these Masked

CodePudding user response:

If you mask an IP still there is a chance for your IP to get exposed. As anybody can simply check your domain DNS records and find the MongoDB server's IP address. I'd suggest you keep what you have right now and focus on security. To project your MongoDB a good password and moreover, a good firewall configuration is enough. You may put a good password and use your server's firewall to grant specific IPs to access your server's port 27017. In this way, even they can see your IP they can't use your MongoDB server unless you whitelist their IP in the firewall.

CodePudding user response:

I'm gonna assume you are trying to access the database directly from react since it is marked in the tags and you are asking this question;

Usually you don't access databases directly from the client in the case of a web application, you put a layer of APIs in between, so the client make requests to the APIs and only them connect to the database, then you can protect your APIs with a firewall and some auth rules if you need conditional access

  • Related