Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
968 views
in Technique[技术] by (71.8m points)

node.js - Connect to MongoDB database using mongoose behind a proxy

I am using mongoose to connect to my database in mongolab in my server.js file :

mongoose.connect('mongodb://MyUsername:MyPassword@ds089702.mongolab.com:89702/todo'); 

When i launch my server with node server.js command, i see this error in my terminal

failed to connect to [ds089702.mongolab.com:89702]

I am very sure that is just a corporate proxy problem, so I'm wondering how can I connect to my database over the corporate proxy using mongoose ?

Thank you!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I had the same problem and figured out a solution that worked for me.

Example mongodb URI:

mongodb://:@ds123456.mlab.com:37409/dbName

  1. Use a proxy client (e.g. Proxifier).
  2. Create a HTTPS proxy through port 8080 using your corporate proxy as the address.

enter image description here

  1. Create a rule for mlab using your URI's port as the target port, which uses the HTTPS proxy you created above as its action.

enter image description here

  1. Prioritize your mlab rule high in the rules list.

enter image description here


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...