0

I want to run nginx to redirect requests to mongodb and a webservice both. I tried to use both server and stream directive but I was not able to get it right.

What should be the configuration file which I can use so that when I contact nginx server on 27017 port, I can access mongodb and when I access it on another webserver port, I should be redirected to the webservice running on tomcat.

nikvys
  • 1

1 Answers1

0

The standard way to do this is with multiple server blocks, e.g.

server {
    listen 27017;

    proxy_pass <mongodb>;
}

server {
    listen 80;

    proxy_pass <webservice>;
}

Obviously <mongodb> and <webservice> should be replaced with whatever method you're using to connect to those services locally.

Joseph Montanaro
  • 548
  • 1
  • 4
  • 13