解决nginx: [emerg] unknown directive “stream“ in /etc/nginx/nginx.conf问题

news/2024/4/25 19:16:42/文章来源:https://blog.csdn.net/User_bie/article/details/128102168

文章目录

    • 1.未报错时nginx配置:
    • 2.报错时nginx配置:
    • 3.增加配置报错:
    • 4.增加配置位置如下:
    • 5.解决办法:
    • 6.测试:nginx -t


1.未报错时nginx配置:

#user  nginx;
user  root;
worker_processes  auto;error_log  /var/log/nginx/error.log notice;
pid        /var/run/nginx.pid;events {worker_connections  1024;
}http {include       /etc/nginx/mime.types;default_type  application/octet-stream;log_format  main  '$remote_addr - $remote_user [$time_local] "$request" ''$status $body_bytes_sent "$http_referer" ''"$http_user_agent" "$http_x_forwarded_for"';# access_log  /var/log/nginx/access.log  main;client_max_body_size 30m;client_body_buffer_size 10m;sendfile        on;#tcp_nopush     on;keepalive_timeout  65;#gzip  on;upstream wms-admin-web {server 192.168.0.2:8082 max_fails=2 fail_timeout=10s;server 192.168.0.3:8082 max_fails=2 fail_timeout=10s;server 192.168.0.203:8082 max_fails=2 fail_timeout=10s;#server 192.168.0.221:8082 max_fails=2 fail_timeout=10s;}upstream wms {server 192.168.0.2:8083 max_fails=2 fail_timeout=10s;#server 192.168.0.221:8083 max_fails=2 fail_timeout=10s;}upstream nacos_server {server 192.168.0.2:8848  weight=1 max_fails=1 fail_timeout=10s;server 192.168.0.3:8848  weight=1 max_fails=1 fail_timeout=10s;server 192.168.0.203:8848  weight=1 max_fails=1 fail_timeout=10s;}server {listen       80;server_name  localhost;rewrite_log on;error_log    /var/log/nginx/error.log notice;location / {root   /home/nginx/html;#root   /usr/share/nginx/html;index index.html /home/nginx/index.html;#	proxy_pass http://wms-admin-web;} }server {listen       8090;server_name  localhost;rewrite_log on;error_log      /var/log/nginx/error.log notice;location /download/ {root /home/nginx/;}location /img/ {root /home/nginx/;}location / {proxy_pass http://wms;proxy_set_header Host $host:$server_port;} }# nacos-server配置server {listen 8858;server_name nacos.com; #nacos.com 映射配置location / {proxy_pass http://nacos_server;proxy_set_header Host $host;proxy_set_header X-Real-IP $remote_addr;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;proxy_set_header REMOTE-HOST $remote_addr;add_header X-Cache $upstream_cache_status;add_header Cache-Control no-cache;}}include /etc/nginx/conf.d/*.conf;
}

2.报错时nginx配置:

load_module /usr/lib64/nginx/modules/ngx_stream_module.so;
#user  nginx;
user  root;
worker_processes  auto;error_log  /var/log/nginx/error.log notice;
pid        /var/run/nginx.pid;events {worker_connections  1024;
}#redis代理测试
stream {upstream redis {#redis真实访问地址server  192.168.0.2:6701 max_fails=3 fail_timeout=30s;}server {#外网监听地址listen 6379;#代理连接超时时间proxy_connect_timeout 5s;#代理超时时间proxy_timeout 30s;#代理名称proxy_pass redis;}
}http {include       /etc/nginx/mime.types;default_type  application/octet-stream;log_format  main  '$remote_addr - $remote_user [$time_local] "$request" ''$status $body_bytes_sent "$http_referer" ''"$http_user_agent" "$http_x_forwarded_for"';# access_log  /var/log/nginx/access.log  main;client_max_body_size 30m;
client_body_buffer_size 10m;sendfile        on;#tcp_nopush     on;keepalive_timeout  65;#gzip  on;upstream wms-admin-web {server 192.168.0.2:8082 max_fails=2 fail_timeout=10s;server 192.168.0.3:8082 max_fails=2 fail_timeout=10s;server 192.168.0.203:8082 max_fails=2 fail_timeout=10s;#server 192.168.0.221:8082 max_fails=2 fail_timeout=10s;}upstream wms {server 192.168.0.2:8083 max_fails=2 fail_timeout=10s;#server 192.168.0.221:8083 max_fails=2 fail_timeout=10s;}upstream nacos_server {server 192.168.0.2:8848  weight=1 max_fails=1 fail_timeout=10s;server 192.168.0.3:8848  weight=1 max_fails=1 fail_timeout=10s;server 192.168.0.203:8848  weight=1 max_fails=1 fail_timeout=10s;}server {listen       80;server_name  localhost;rewrite_log on;error_log    /var/log/nginx/error.log notice;location / {root   /home/nginx/html;#root   /usr/share/nginx/html;index index.html /home/nginx/index.html;#	proxy_pass http://wms-admin-web;} }server {listen       8090;server_name  localhost;rewrite_log on;error_log      /var/log/nginx/error.log notice;location /download/ {root /home/nginx/;}location /img/ {root /home/nginx/;}location / {proxy_pass http://wms;proxy_set_header Host $host:$server_port;} }# nacos-server配置server {listen 8858;server_name nacos.com; #nacos.com 映射配置location / {proxy_pass http://nacos_server;proxy_set_header Host $host;proxy_set_header X-Real-IP $remote_addr;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;proxy_set_header REMOTE-HOST $remote_addr;add_header X-Cache $upstream_cache_status;add_header Cache-Control no-cache;}}include /etc/nginx/conf.d/*.conf;}

3.增加配置报错:

增加配置内容如下:

#redis代理测试
stream {upstream redis {#redis真实访问地址server  192.168.0.2:6701 max_fails=3 fail_timeout=30s;}server {#外网监听地址listen 6379;#代理连接超时时间proxy_connect_timeout 5s;#代理超时时间proxy_timeout 30s;#代理名称proxy_pass redis;}
}

4.增加配置位置如下:

在这里插入图片描述

5.解决办法:

1.nginx -V确保nginx安装了–with -stream如果没有,重新用yum install nginx -y安装
2. 安装 yum -y install epel-release
3. yum -y install nginx-all-modules.noarch
4.vi nginx.conf顶部加一行
load_module /usr/lib64/nginx/modules/ngx_stream_module.so;

6.测试:nginx -t

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.luyixian.cn/news_show_38700.aspx

如若内容造成侵权/违法违规/事实不符,请联系dt猫网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

群晖外网访问终极解决方法:IPV6+阿里云ddns+ddnsto

写在前面的话 受够了群晖的quickconnet的小水管了,急需一个新的解决方法,这是后发现移动没有公网IP,只有ipv6(公网的),时候有小伙伴要问,要是没有ipv6就没办法访问群晖了吗? 不&…

微信截图无法发送,也发不出电脑上的图片

微信截图无法发送,也发不出电脑上的图片 现象 今天微信突然出现这个问题,怎么改设置都调不好,卸载重装都不行,最后发现,微信的消息目录中,一些文件无法删除,提示“文件或目录损坏且无法读取”…

TinyML:是否是FPGA在人工智能方面的最佳应用?

TinyML 也是机器学习的一种,他的特点就是缩小深度学习网络可以在微型硬件中使用,主要应用在智能设备上。超低功耗嵌入式设备正在“入侵”我们的世界,借助新的嵌入式机器学习框架,它们将进一步推动人工智能驱动的物联网设备的普及。…

sipp: bind_local;watchdog timer trip

文章目录作为服务端时,source ip 随机的问题命令示例bind_localwatchdog_minor_maxtriggers作为服务端时,source ip 随机的问题 https://sipp.sourceforge.net/doc/reference.html https://github.com/SIPp/sipp/issues/83 https://github.com/SIPp/sip…

虹科分享 | 网络流量监控 | 使用 ntopng 收件人和端点进行灵活的警报处理

在之前,ntopng引擎对所有警报的配置是单一的:进入偏好页面并指定警报的发送地点。但这是不理想的,原因有很多:包括不可能在不同的渠道向不同的收件人发送警报,或有选择地决定何时发送警报。 出于这个原因,…

北大惠普金融指数-匹配企业绿色创新指数2011-2020年:企业名称、年份、行业分类等多指标数据

1、数据来源:北京大学数字金融中心、国家统计局、国家专利产权局等部门公开数据 2、时间跨度:2011-2020年 3、区域范围:全国 4、指标说明: 中国内地31个省(直辖市、自治区,简称“省”)、337…

网络安全工程师必备证书有哪些?

网络环境之间的竞争,归根到底优秀人才之间的竞争。 在2022年网络安全周上,《网络安全人才实战能力白皮书》正式公布。资料显示,到2027年,我国网络安全人员缺口将达327万,而高校人才培养经营规模仅是3万/年。 那样&am…

小程序数据请求的方式和注意事项

1.小程序中网络数据请求的限制 出于安全性方面的考虑,小程序官方对数据接口的请求做出了如下两个限制: ① 只能请求HTTPS类型的接口 ② 必须将接口的域名添加到信任列表中 2.配置request合法域名 假设要在自己的微信小程序中,希望请求某…

【JavaScript作用域】

JavaScript作用域1 本节目标2 作用域2.1 作用域概述2.2 全局作用域2.3 局部作用域3 变量的作用域3.1 变量作用域的分类3.2 全局变量3.3 局部变量3.4 从执行效率看全局变量与局部变量3.5 JS没有块级作用域4 作用域链1 本节目标 说出JavaScript的两种作用域区分全局变量和局部变…

关系抽取(二)远程监督方法总结

目录 前言 1. 远程监督关系抽取开山之作 1.1 介绍 1.2 训练过程 1.2.1 数据标注方法 1.2.2 训练方法 1.3 测试过程 1.4 思考 1.5 总结 2. PCNN 2.1 介绍 2.2 模型结构 2.2.1 文本特征表示 2.2.2 卷积 2.2.3 分段最大池化 2.2.4 softmax多分类 2.3 多实例学习的…

React Server Component: 混合式渲染

作者:谢奇璇 React 官方对 Server Comopnent 是这样介绍的: zero-bundle-size React Server Components。 这是一种实验性探索,但相信该探索是个未来 React 发展的方向,与 React Server Component 相关的周边生态正在积极的建设当中。 术语…

Spring Cloud OpenFeign - - - >拦截器

源码地址:https://download.csdn.net/download/weixin_42950079/87209379 SpringMVC拦截器 和 OpenFeign拦截器 的区别 初学者很容易将 Spring MVC 拦截器 和 Spring Cloud OpenFeign 拦截器搞混,误以为OpenFeign拦截器就是SpringMVC拦截器: …

Kotlin高仿微信-第9篇-单聊-文本

Kotlin高仿微信-项目实践58篇详细讲解了各个功能点,包括:注册、登录、主页、单聊(文本、表情、语音、图片、小视频、视频通话、语音通话、红包、转账)、群聊、个人信息、朋友圈、支付服务、扫一扫、搜索好友、添加好友、开通VIP等众多功能。 Kotlin高仿…

Spark系列之Spark的数据倾斜

title: Spark系列 第九章 Spark的数据倾斜 9.1 Spark调优概述 ​ 有的时候,我们可能会遇到大数据计算中一个最棘手的问题——数据倾斜,此时 Spark 作业的性能会比期望差很多。数据倾斜调优,就是使用各种技术方案解决不同类型的数据倾斜问题…

2022腾讯全球数字生态大会【存储专场】它来了|预约有礼

它来了!它来了! 2022腾讯全球数字生态大会【存储专场】它来了! 作为腾讯集团产业互联网规格最高、规模最大、覆盖面最广的年度盛会 今年存储专场与您一起探讨 分布式高性能存储与数据分析处理的科技创新和最新成果 存储会场六大亮点&…

PyQt5可视化编程-事件、信号和对话框

一、概述: 所有的应用都是事件驱动的。事件大部分都是由用户的行为产生的,当然也有其他的事件产生方式,比如网络的连接,窗口管理器或者定时器等。调用应用的exec_()方法时,应用会进入主循环,主循环会监听和分发事件。…

【SpringBoot】对于yaml的详细学习和三种属性赋值的实战详解

一.yaml详细讲解 1.1 什么是yaml? YAML是一种数据序列化语言,通常用于编写配置文件。业界对YAML有不同的看法。有些人会说YAML代表另一种标记语言。其他人认为“YAML不是标记语言”(“YAML并非标记语言”)。“YAML”只是这句话的…

CDMP选修课都有什么?

大家都知道CDMP认证考试有四个级别。分别是A级(基础级)P级(实践级)M级(专业级)F级(大师级)。级别越高,考试难度就越大,分数比例要求也更高,相对应…

Unity ab包加载文本 puerts 自定义loader

输出ab包 他会把你创建的ab包都打包 也就是在这里的创建的 string assetBundleDirectory Path.Combine(Application.streamingAssetsPath, "OutAssetBundles"); if (!Directory.Exists(assetBundleDirectory)) {Directory.CreateDirectory(assetBundleDirectory);…

【HIT-OSLAB-实验中的碎碎念】

文章目录应该养成的好习惯删除 替换 修改 内容时 记得留备份遇到问题要通过文字 图片 等多种途径去记录不同的项目应该在不同的文件夹进行处理代码文档 记得添加一些注释用于说明功能多输出有区别度的提示信息s找bug 先定位错误 再改当一份代码有不同版本的时候 记得说明每份代…