NGINX Unknown Directive Stream
Asked Answered
A

3

6

I'm trying to setup a UDP Load Balancer using NGINX (1.12.1).

However I'm getting an error...

[ec2-user@ip-172-31-0-184 nginx]$ sudo service nginx start Starting nginx: nginx: [emerg] unknown directive "stream" in /etc/nginx/conf.d/load-balancer.conf:1

Here is the config I'm trying to use:

stream {
        upstream backend1 {
                server 10.0.1.50:450;
        }

upstream backend2 {
                server 10.0.1.50:500;
        }

# This server accepts all traffic to port 80 and passes it to the upstream.
        # Notice that the upstream name and the proxy_pass need to match.

        server {
                listen 500 udp;
                proxy_pass backend2;
        }

server {
                listen 4500 udp;
                proxy_pass backend1;
        }

}

And here is the output of nginx -V, to verify that stream is installed.

[ec2-user@ip-172-31-0-184 nginx]$

th=/var/log/nginx/access.log --http-client-body-temp-path=/var/lib/nginx/tmp/client_body --http-proxy-temp-path=/var/lib/nginx/tmp/proxy --http-fastcgi-temp-path=/var/lib/nginx/tmp/fastcgi --http-uwsgi-temp-path=/var/lib/nginx/tmp/uwsgi --http-scgi-temp-path=/var/lib/nginx/tmp/scgi --pid-path=/var/run/nginx.pid --lock-path=/var/lock/subsys/nginx --user=nginx --group=nginx --with-file-aio --with-ipv6 --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-http_addition_module --with-http_xslt_module=dynamic --with-http_image_filter_module=dynamic --with-http_geoip_module=dynamic --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_degradation_module --with-http_slice_module --with-http_stub_status_module --with-http_perl_module=dynamic --with-http_auth_request_module --with-mail=dynamic --with-mail_ssl_module --with-pcre --with-pcre-jit --with-stream=dynamic --with-stream_ssl_module --with-google_perftools_module --with-debug --with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic' --with-ld-opt=' -Wl,-E'

Can anyone please help me?

Aureole answered 14/6, 2018 at 6:25 Comment(0)
R
6

Install the following package then your issue vanished yum install nginx-mod-stream.x86_64

Rootstock answered 30/8, 2021 at 6:52 Comment(1)
For ubuntu: apt get install -y libnginx-mod-streamGermanism
C
3

The stream { ... } block is a top-level block. The files included from /etc/nginx/conf.d/ are probably included into the http { ... } block. Check your nginx.conf file (probably located in /etc/nginx), and locate the include directives.

Curia answered 14/6, 2018 at 8:33 Comment(1)
and --with-stream=dynamic - serverfault.com/a/858074/55482Bodwell
E
1

This fixed issue for me:

sudo apt-get install nginx-full

Emilioemily answered 14/7 at 20:41 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.