[server] /etc/nginx/nginx.conf에서 알 수없는 지시어“스트림”: 86

나는 nginx/1.12.0문서마다 stream모듈 을 포함하고 있습니다 . 다음 명령으로 nginx를 설치했습니다.

sudo add-apt-repository ppa:nginx/stable
sudo apt-get update
sudo apt-get install nginx
nginx -v
nginx version: nginx/1.12.0

에 스트림 지시문을 추가하려고했습니다 nginx.conf.

stream {
    upstream sys {
        server 172.x.x.x:9516;
        server 172.x.x.x:9516;
    }
    server {
        listen 9516 udp;
        proxy_pass sys;
    }
}

하지만 다시 시작할 때 로그에 nginx오류가 발생합니다.nginx

unknown directive "stream" in /etc/nginx/nginx.conf:86

nginx -V output
nginx version: nginx/1.12.0
built with OpenSSL 1.0.1f 6 Jan 2014
TLS SNI support enabled
configure arguments: --with-cc-opt='-g -O2 -fPIE -fstack-protector --param=ssp                                                                                          -buffer-size=4 -Wformat -Werror=format-security -fPIC -D_FORTIFY_SOURCE=2' --w                                                                                          ith-ld-opt='-Wl,-Bsymbolic-functions -fPIE -pie -Wl,-z,relro -Wl,-z,now -fPIC'                                                                                           --prefix=/usr/share/nginx --conf-path=/etc/nginx/nginx.conf --http-log-path=/                                                                                          var/log/nginx/access.log --error-log-path=/var/log/nginx/error.log --lock-path                                                                                          =/var/lock/nginx.lock --pid-path=/run/nginx.pid --modules-path=/usr/lib/nginx/                                                                                          modules --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-p                                                                                          ath=/var/lib/nginx/fastcgi --http-proxy-temp-path=/var/lib/nginx/proxy --http-                                                                                          scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi                                                                                           --with-debug --with-pcre-jit --with-http_ssl_module --with-http_stub_status_m                                                                                          odule --with-http_realip_module --with-http_auth_request_module --with-http_v2                                                                                          _module --with-http_dav_module --with-http_slice_module --with-threads --with-                                                                                          http_addition_module --with-http_geoip_module=dynamic --with-http_gunzip_modul                                                                                          e --with-http_gzip_static_module --with-http_image_filter_module=dynamic --wit                                                                                          h-http_sub_module --with-http_xslt_module=dynamic --with-stream=dynamic --with                                                                                          -stream_ssl_module --with-stream_ssl_preread_module --with-mail=dynamic --with                                                                                          -mail_ssl_module --add-dynamic-module=/build/nginx-ZgS12K/nginx-1.12.0/debian/                                                                                          modules/nginx-auth-pam --add-dynamic-module=/build/nginx-ZgS12K/nginx-1.12.0/d                                                                                          ebian/modules/nginx-dav-ext-module --add-dynamic-module=/build/nginx-ZgS12K/ng                                                                                          inx-1.12.0/debian/modules/nginx-echo --add-dynamic-module=/build/nginx-ZgS12K/                                                                                          nginx-1.12.0/debian/modules/nginx-upstream-fair --add-dynamic-module=/build/ng                                                                                          inx-ZgS12K/nginx-1.12.0/debian/modules/ngx_http_substitutions_filter_module

나는이 오류를 봤으며 일부 사람들은이 모듈을 별도로 설치 / 구성해야한다고 말합니다. 일부는 nginx1.12.0 릴리스 와 함께 제공됩니다 . 누군가 이미 설치된 모듈에서이 모듈을 설치 / 구성하는 방법을 제안 할 수 있습니까 nginx?

VG 감사합니다



답변

스트림 모듈은 다음과 같이 동적으로 추가됩니다.

--with-stream=dynamic

‘정적’이어야하므로 모듈을 직접로드하십시오. 이렇게하려면 nginx.conf 맨 위에 다음을 추가하십시오.

load_module /usr/lib/nginx/modules/ngx_stream_module.so;

그때:

nginx -t

모든 것이 잘되면 :

nginx -s reload
service nginx restart

편집하다:

-s signal' Send signal to the master process. The argument signal can be one of: stop, quit, reopen, reload. The following table shows the corresponding system signals.

stop' SIGTERM
quit' SIGQUIT
reopen' SIGUSR1
reload' SIGHUP


답변

Joe의 답변에 대한 평판이 충분하지 않으므로 여기에 작성하십시오.

CentOS7에서 lib64 폴더 아래에있는 모듈 경로. 따라서 다음 줄을 추가해야합니다.

load_module '/usr/lib64/nginx/modules/ngx_stream_module.so';


답변

nginxAWS EC2 인스턴스에서 실행되는 Amazon Linux 에서이 문제가 발생했으며 /usr/lib64/nginx/modules/폴더가 비어있었습니다.

나는 다음과 같이 모듈을 설치했다 yum:

yum install nginx-mod-stream

stream지시어는 변경없이 지금 작동합니다 nginx.conf.


답변