Hi guys I am trying to setup Nginx as a reverse proxy for accessing a MongoDB Database. By default Mongo listens to 27017 port. What I want to do, is redirect a hostname for
I left this behind, but after some work done, I had to face this problem again and the solution popped in my mind this time!
NGINX is basically an HTTP server, so by setting redirects and proxies the above way, it wraps all communication in HTTP protocol. So the error that is happening, is that while Mongo is expecting Raw TCP traffic, it is getting HTTP traffic.
So the solution to this is to use NGINX's new stream module
that is used for handling raw TCP traffic and setup your upstream server to point to mongodb instance.
More Info : NGINX stream module