Using Meteor behind a proxy is not working

#1

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:

HTTP_PROXY=http://user:password@1.2.3.4:5678
HTTPS_PROXY=http://user:password@1.2.3.4:5678

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?

1 Like
#2

Need more information to understand your problem @@

#3

What specifically would you like to know? Happy to provide further clarification :slight_smile:

#4

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.

#5

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?

#6

Unfortunately, the way to do is through meteor is by copying the mongo package directory out of github.com/meteor/meteor, then in the command line

meteor remove mongo
meteor add mongo

And finally, editing the file like I described. Then it won’t be one off.