• -------------------------------------------------------------
  • ====================================

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

技能 dewbay 2年前 (2022-11-01) 2106次浏览 已收录 0个评论 扫描二维码

问题原因

在 nginx 中增加了这个配置

[root@k8s-node2 ~]# cat /etc/nginx/nginx.conf
stream {
    upstream kube-apiserver {
        server 192.168.10.64:6443     max_fails=3 fail_timeout=30s;
        server 192.168.10.65:6443     max_fails=3 fail_timeout=30s;
    }
    server {
        listen 7443;
        proxy_connect_timeout 2s;
        proxy_timeout 900s;
        proxy_pass kube-apiserver;
    }
}

nginx -t 报错

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

解决方法

# 安装 nginx 源
curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
# 先安装
yum -y install epel-release

#应该是缺少 modules 模块
yum -y install nginx-all-modules.noarch
然后在用 nginx -t 就好了
[root@k8s-node2 ~]# nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

露水湾 , 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:解决nginx: [emerg] unknown directive “stream“ in /etc/nginx/nginx.conf问题
喜欢 (0)
[]
分享 (0)
关于作者:
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址