Quantcast
Channel: Techathon »» Mongodb | Techathon
Viewing all articles
Browse latest Browse all 3

How to securely configure mongodb in production environment

$
0
0

Step1:

Install mongodb from here as per your operating system [ linux,window,mac].

Step2:

connect or login to mongodb using below command :

mongo 127.0.0.1:27001

Step 3:

Create an admin user using this command :

use admin;
db.addUser( { user: "mongoadmin",
              pwd: "password",
              roles: [ "userAdminAnyDatabase" ] } );

Step 4:

Now, Create user with specific permission or role ( readwrite , dbAdmin) for database using given command

For more detail can see mongo doc

use dbname;
db.addUser( { user: "username",
              pwd: "password",
              roles: [ "readWrite", "dbAdmin" ]
            } );

Step 5:

Now, We will block or disable mongo port 27001 for outsider. This port will allow only for localhost or 127.0.0.1

To block this port ,you need to open nano /etc/sysconfig/iptables

Now put given lines in this file before COMMIT

-A INPUT -p tcp -s localhost –dport 27017 -j ACCEPT
-A INPUT -p tcp –dport 27017 -j DROP

 

Then, You will have to restart using this command service iptables restart

Now your mongodb production environment have been configured securely ………so enjoy..

The post How to securely configure mongodb in production environment appeared first on Techathon.


Viewing all articles
Browse latest Browse all 3

Trending Articles