I am connecting to an external Mongo DB that only accepts certain IPs. I have a Meteor instance running on Heroku, and I have a Quotaguard static URL that I am trying to route Meteor through so I can connect to the Mongo server from that IP address. Currently I have two environment variables on Heroku:
However, when I check the logs, the application was not connecting to the database from my proxy IP. It was connecting as if there were no proxy. Is there an extra step I must take on Heroku?
In all likelihood, Meteor’s database connection code doesn’t respect proxies whose configuration is exposed as environment variables.
Mongo doesn’t communicate with HTTP or HTTPS, so you’re going to want to use a SOCKS (TCP-supporting) proxy instead.
You can follow the exact example here, except use meteor npm install instead of npm install, and just set up the socks connection.
If this is really important to achieve, my recommendation: You can copy-and-paste the mongo package directory out of the meteor github repo directly into the packages directory of your project, and then meteor install mongo to allow you to modify the connection code I’ve highlighted for you without forking all of meteor. Then follow the example on Heroku’s QuotaGuard documents.
Thanks a lot for the answer. Is there a way to do this via Meteor, though? The code on the QuotaGuard website seemed to be for “one-off” connections – i.e. connecting once, performing the update, then quitting the process. Is there a way to use SOCKS when performing an Insert operation via Meteor?