0

I've got a replicaSet with three nodes. I'm using a connections string of the following format to connect to the replicaSet:

mongodb://user:pass@host_ip_1:port,host_ip_2:port,host_ip_3:port/database?authSource=admin&replicaSet=name_of_replica&readPreference=secondaryPreferred

where host_ip_1, host_ip_2, host_ip_3 are IP addresses (e.g., 10.234.3.45, 46, 47)

I want to create a domain which would hide all these IP addresses and allow me to use the connection string as follows:

mongodb://user:pass@mongo_domain:port/database?...

But I also what such options like readPreference=secondaryPreferred to be still working.

How can I do this?

Alexander Goida
  • 305
  • 1
  • 11
  • I understand that, for example NGINX, should be configured somehow. But how? – Alexander Goida Feb 02 '22 at 17:25
  • it seems this was already answered here (the stream module support raw tcp ): https://stackoverflow.com/questions/31853755/how-to-setup-mongodb-behind-nginx-reverse-proxy – R2D2 Feb 02 '22 at 18:34
  • I saw it. It seems it's not what I need, bcs it explains how to configure NGINX for a single server, not for the replica. To be honest, I'm not sure if this is possible. The difference is that in my case I want to hide multiple endpoints behind one. And I want still be able to write to one server, but read from another (from replica) – Alexander Goida Feb 07 '22 at 09:27

0 Answers0