Remote MONGO Connection over SSH Tunnel

Hi !
Wonderful MUP.Using kadirahq/meteor-up with Meteor 1.4.x Works great for deployment.

I have two droplets on DO.
Srv1> running MONGO on 27017 &
Other Srv2> is where I am planning to Run Meteor.

I want to be able to connect to Mongo on Srv2> over SSH and have set up SSH Tunnel between Srv1> and Srv2> & have made necessary changes to firewall and mongo conf on Srv2>

For SSH tunnel did on Srv1> – ssh -L 4321:localhost:27017 user@your.ip.address -f -N on

When I do mongo --port 4321 on Srv1> - am able to connect, query and see the DB on Srv2>

Now in Mup
a> Tried to start and connect to MONGO on Srv1> itself - it works great.
b> Removed “mongo” section and in MONGO_URL if I set <IP_OF_2:27017>\meteor - I am able to connect to it and it works good. (So this is connecting thro firewall to MongodB on Srv 2 but not through SSH)

Now to be able to connect the Meteor on Srv1> and Mongo Srv2> over SSH - I tried various options
but not able to connect. While Deployment Verification the deployment fails.

I have tried removing “mongo” section and setting MONGO_URL as
mongodb://, mongodb://localhost:4321/,

Also tried

keeping “mongo” section with port as “4321” and removing port # from MONGO_URL but no luck.

Anyone tried this? Am I missing this… or MUP assumes that Localhost only as Docker container?
Any other option I am missing, don’t know ?

If mongo is running as a docker container you should use its internal url (which is probably when you set the ssh tunnel

Or you may run the container with -p 4321:27017 though at that point your mongodb would be accessible from the outside (like from your serverip:4321) by anyone if it’s not protected with user/password

1 Like

Thx! Will try and confirm