Setting up mongodb behind nginx

Solution 1:

Check nginx.conf where the sites-enabled files are included.

Thats probably done in the http section of the conf file, but the stream directive is only allowed in the main section as stated here: http://nginx.org/en/docs/stream/ngx_stream_core_module.html#stream

You have to move your directive in nginx.conf file itself:

user ...
...
http {
  ...
}
stream {
  ...
}