1.9 stream not working? 'directive is not allowed here'

Hmm, following:

I get a nginx: [emerg] “stream” directive is not allowed here
eventhough its within the http context like upstreams are, anyone with a
good example? or did I stumble on a context eval bug?

Posted at Nginx Forum:

On 4/29/15 12:13 AM, itpp2012 wrote:

Hmm, following: TCP and UDP Load Balancing | NGINX Documentation
I get a nginx: [emerg] “stream” directive is not allowed here
eventhough its within the http context like upstreams are, anyone with a
good example? or did I stumble on a context eval bug?

Put it in the same level as http. E.g.


http { foo }

stream { bar }

EOF


Maxim K.

On 29.04.2015 00:13, itpp2012 wrote:

Hmm, following: TCP and UDP Load Balancing | NGINX Documentation
I get a nginx: [emerg] “stream” directive is not allowed here
eventhough its within the http context

You need to define it in the main context.

See Module ngx_stream_core_module for details.

It needs to be at the -same- level as the http {} block, not -within-
the
http {} block.

worker_processes 4;

events {
worker_connections 8192;
}

http {
include mime.types;
default_type application/octet-stream;
}

stream {
upstream stream_backend {
server 192.168.222.22:810 weight=5;
server 192.168.222.17:810 weight=5;
}
server {
listen 12345;
proxy_pass stream_backend;
}
}

Minimal conf;

worker_processes 4;

events {
worker_connections 8192;
}

http {
include mime.types;
default_type application/octet-stream;

stream {
    upstream stream_backend {
        server 192.168.222.22:810 weight=5;
        server 192.168.222.17:810 weight=5;
    }
}

server {
    listen     12345;
    proxy_pass stream_backend;
}

}

nginx -t
nginx: [emerg] “stream” directive is not allowed here in
conf\nginx.conf:11
nginx: configuration file conf\nginx.conf test failed

Whats incorrect here then?

Posted at Nginx Forum:

Robert P. Wrote:

It needs to be at the -same- level as the http {} block, not -within-
the http {} block.

Ah! makes sense as a stream is not http.
That passes -t

Posted at Nginx Forum: