Mongodb – How to create a Mongo config file to allow access to http on port 28017

configurationmongodbmongodb-3.0

Well I want to configure the mongo server to allows access for http.

I put this on my mongo config file:

port = 28017
rest = true

And when I restart my mongod service and try to access I got this message on the browser.

It looks like you are trying to access MongoDB over HTTP on the native
driver port.

I check my logs:

cat /log/mongod.log
2015-08-07T18:07:27.430+0000 [initandlisten] MongoDB starting : pid=20333 port=28017 dbpath=/data 64-bit host=ip-x-y-z-d
2015-08-07T18:07:27.430+0000 [initandlisten] db version v2.6.10
2015-08-07T18:07:27.430+0000 [initandlisten] git version: 5901dbfb49d16eaef6f2c2c50fba534d23ac7f6c
2015-08-07T18:07:27.430+0000 [initandlisten] build info: Linux build18.nj1.10gen.cc 2.6.32-431.3.1.el6.x86_64 #1 SMP Fri Jan 3 21:39:27 UTC 2014 x86_64 BOOST_LIB_VERSION=1_49
2015-08-07T18:07:27.430+0000 [initandlisten] allocator: tcmalloc
2015-08-07T18:07:27.430+0000 [initandlisten] options: { config: "/etc/mongod.conf", net: { http: { RESTInterfaceEnabled: true, enabled: true }, port: 28017 }, processManagement: { fork: true }, security: { authorization: "enabled" }, storage: { dbPath: "/data" }, systemLog: { destination: "file", path: "/log/mongod.log" } }
2015-08-07T18:07:27.434+0000 [initandlisten] journal dir=/data/journal
2015-08-07T18:07:27.434+0000 [initandlisten] recover : no journal files present, no recovery needed
2015-08-07T18:07:27.778+0000 [initandlisten] waiting for connections on port 28017
2015-08-07T18:07:27.778+0000 [websvr] admin web console waiting for connections on port 29017

I refresh the browser and the logs show me that:

2015-08-07T18:24:09.246+0000 [initandlisten] connection accepted from 181.196.26.130:64683 #24 (1 connection now open)
2015-08-07T18:24:09.246+0000 [conn24] end connection IPAddress:64683 (0 connections now open)
2015-08-07T18:24:09.493+0000 [initandlisten] connection accepted from 181.196.26.130:53343 #25 (1 connection now open)
2015-08-07T18:24:09.493+0000 [conn25] end connection IPAddress:53343 (0 connections now open)

So If the log says that it waiting for connection on that port give me a respond but I can't see the http admin view, any idea or tips?

Best Answer

You're on RHEL6 or a derivative from your kernel version 2.6.32-431.3.1.el6.x86_64. The default firewall only allows ssh incoming. You'll need to poke a hole in your firewall. Look here for firewall tips:

http://wiki.centos.org/HowTos/Network/IPTables