1

I have mongo DB container running in the cloud. now I can connect to my container using robot3t or mongo compass from my desktop application by simply providing this details.

hostname= 192.xx.xx.x  (ipaddress)
username = myusername
password = mypassword
authdatabase = mydatabse

Now I want to connect to my mongo DB container not with an IP address but using my domain name like this below

hostname= mydomain.com  (domain)
username = myusername
password = mypassword
authdatabase = mydatabse

I tried the stream module in Nginx 1.4 didn't get any result

I get an error like 13834 is already bind (98....)

stream {
    server {
        listen  13834;
        proxy_connect_timeout 1s;
        proxy_timeout 3s;
        proxy_pass    stream_mongo_backend;
    }

    upstream stream_mongo_backend {
      server mydomain.com:13834;
  }
}

please help me

more info:- I am using bitnami MongoDB image:4.0

Rizwan
  • 163
  • 2
  • 8
  • Is your Nginx in a container? Why Nginx listen `13814`, is this mongo container export port? – menya Jul 05 '19 at 12:03
  • you are trying to listen to the port 13834 while mongo is also listening to. There should be only 1 service listening at 1 port at a time. – flaixman Jul 05 '19 at 13:29
  • i don't have any idea of stream module in nginx i jjust followed this answer i stack over flow [link](https://stackoverflow.com/questions/31853755/how-to-setup-mongodb-behind-nginx-reverse-proxy) . – Rizwan Jul 05 '19 at 15:09
  • @menya nginx is not docker container it's installed in Ubuntu by using commands – Rizwan Jul 05 '19 at 15:13
  • @flaixman yes I think you are right. my goal is to connect to Mongo DB using my domain not with IP address how can I achieve using nginx or any other technology – Rizwan Jul 05 '19 at 15:15
  • https://www.datduh.com/blog/2017/7/26/how-to-connect-to-mongodb-atlas-using-robo-3t-robomongo set the port of the configuration at "13844" and in nginx listen "13844", this should at least let you start your nginx. – flaixman Jul 05 '19 at 15:19
  • installed my nginx running at port 80. then i change default.conf file to like this. `server {listen 80 default_server;server_name mydomain.com;} ` then mongo db is runnign in port let say 13814. and now i want to connect my database liek this. `host=mydomain` `port=13814` `username=username` `password=password` – Rizwan Jul 05 '19 at 15:27

0 Answers0