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

Hmm, following:
http://nginx.com/resources/admin-guide/tcp-load-balancing/
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:
http://forum.nginx.org/read.php?2,258463,258463#msg-258463

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

Hmm, following: http://nginx.com/resources/admin-guide/tcp-load-balancing/
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.
http://nginx.com

On 29.04.2015 00:13, itpp2012 wrote:

Hmm, following: http://nginx.com/resources/admin-guide/tcp-load-balancing/
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 http://nginx.org/r/stream 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:
http://forum.nginx.org/read.php?2,258463,258467#msg-258467

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:
http://forum.nginx.org/read.php?2,258463,258481#msg-258481

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs