NGINX 未知指令流

标签 nginx udp load-balancing

我正在尝试使用 NGINX (1.12.1) 设置 UDP 负载平衡器。

但是我收到一个错误...

[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

这是我尝试使用的配置:

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;
        }

}

这里是 nginx -V 的输出,用于验证流是否已安装。

[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'

谁能帮帮我?

最佳答案

stream { ... } block 是顶级 block 。 /etc/nginx/conf.d/ 中包含的文件可能包含在 http { ... } block 中。检查您的 nginx.conf 文件(可能位于 /etc/nginx 中),并找到 include 指令。

关于NGINX 未知指令流,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50850900/

相关文章:

reactjs - 引入ALB后,出现Mixed Content Error

python - Gunicorn - 无法访问 Django 项目(浏览器超时)

apache - 如何从网络服务器调用本地 shell 脚本?

c++ - 向现有 TCP 和 UDP 代码添加 SSL 支持?

c - 原始 LWIP UDP 广播

java - 如何使用带有 DatagramChannel 的 Selector 对象进行非阻塞数据包接收

ssl - 如何使用 nginx 从 http 负载均衡器迁移到 https 负载均衡器

nginx - 在nginx反向代理后面处理flask url_for

Multi-Tenancy 系统中使用 JWT 和外部认证服务器的 Nginx 认证

https - Java EE 表单登录,负载均衡器将 https 转换为 http