Home » Categories » Linux Cloud Server » MongoDB |
How To Securely Configure a Production MongoDB Server |
Article Number: 156 | Rating: Unrated | Last Updated: Sun, Jan 5, 2014 at 8:35 PM
|
Securely Configure a Production MongoDB Server If MongoDB is your document store of
choice, then this article should help you configure everything securely and
properly for a production-ready environment. Steps There are two differently recommended paths that are available. The first is to connect securely to your database through an SSH tunnel. The alternative is to allow connections to your database over the internet. Of the two choices, the former is recommended. Connect Over SSH Tunnel By connecting to your Mongo VIrtual Private Server through
an SSH tunnel, you can avoid a lot of potential security issues. The caveat is
that your server must otherwise be totally locked down with few to no other ports
open. A recommended SSH configuration is key-only or key+password.
Next, run the following command to initialize the connection: # The \s are just to multiline the command and make it more readable ssh \ -L 4321:localhost:27017 \ -i ~/.ssh/my_secure_key \ ssh_user@mongo_db_host_or_ip
Number 2 is really the meat of the instruction. This will determine how you tell your applications or services to connect to your MongoDB. Connect Over the Internet If connecting over an SSH tunnel is
not necessarily an option, you can always connect over the internet. There are
a few security strategies to consider here. # In your MongoDB configuration file, change the following line to something other than 27017 port = 27017 Secondly, you'll want to bind Mongo directly to your application server's IP address. This means that Mongo will only accept connections. # In your MongoDB configuration file, change the following line to your application server's IP address bind_ip = 127.0.0.1 Lastly, consider using MongoDB's authentication feature and set a username and password. To set this up, connect to the MongoDB shell as an admin with the `mongo` command and add a user. Once that's done, make sure you're adding the newly added username/password in your MongoDB connection strings. Conclusion Please consider the above a starting point and not the be-all-end-all for MongoDB security. A key factor NOT mentioned here are server firewall rules. |
Attachments
There are no attachments for this article.
|
How To Implement Replication Sets in MongoDB on an Ubuntu
Viewed 2243 times since Mon, Dec 23, 2013
How To Set Up a Scalable MongoDB Database
Viewed 7936 times since Mon, Dec 23, 2013
How To Install MongoDB on Ubuntu 12.04
Viewed 2635 times since Mon, Dec 23, 2013
How To Connect Node.js to a MongoDB Database
Viewed 7256 times since Mon, Dec 23, 2013
|