mongodbamazon-web-servicesamazon-ec2

I can't connect from the outside to the mongo-express


I am using the mongo-express.

Installed on AWS EC2, it was started.

$ node app
Mongo Express server listening on port 8081 at localhost
Database connected
Connecting to db...
Database db connected

However, it is not possible to connect from the browser to port 8081.

I can download the index.html of the mongo-express using wget command on ec2.

$ wget http://admin:pass@localhost:8081
--2016-02-22 02:22:25--  http://admin:*password*@localhost:8081/
Resolving localhost (localhost)... 127.0.0.1
Connecting to localhost (localhost)|127.0.0.1|:8081... connected.
HTTP request sent, awaiting response... 401 Unauthorized
Authentication selected: Basic realm="Authorization Required"
Reusing existing connection to localhost:8081.
HTTP request sent, awaiting response... 200 OK
Length: 9319 (9.1K) [text/html]
Saving to: ?index.html?

index.html            0%[                    ]       0  --.-KB/s               GET / 200 218.468 ms - 9319
index.html          100%[===================>]   9.10K  --.-KB/s    in 0.04s

2016-02-22 02:22:26 (236 KB/s) - ?index.html? saved [9319/9319]

By the way, port 8081 in the security group of ec2 is open to my IP.


Solution

  • The following settings of config.js is, was the cause

    site: {    // baseUrl: the URL that mongo express will be located at - Remember to add the forward slash at the stard and end!
    baseUrl: '/',
    cookieKeyName: 'mongo-express',
    cookieSecret:     process.env.ME_CONFIG_SITE_COOKIESECRET   || 'cookiesecret',
    host:             process.env.VCAP_APP_HOST                 || 'localhost',
    port:             process.env.VCAP_APP_PORT                 || 8081,
    requestSizeLimit: process.env.ME_CONFIG_REQUEST_SIZE        || '50mb',
    sessionSecret:    process.env.ME_CONFIG_SITE_SESSIONSECRET  || 'sessionsecret',
    sslCert:          process.env.ME_CONFIG_SITE_SSL_CRT_PATH   || '',
    sslEnabled:       process.env.ME_CONFIG_SITE_SSL_ENABLED    || false,
    sslKey:           process.env.ME_CONFIG_SITE_SSL_KEY_PATH   || '',
    },
    

    The value of the host is changed to "0.0.0.0", now to be able to connect from browser to the mongo-express.