解決nginx: [emerg] unknown directive “stream“ in /etc/nginx/nginx.conf問題


鏡像下載、域名解析、時間同步請點擊 阿里雲開源鏡像站

問題原因

在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報錯

file

解決方法

# 安裝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

本文轉自:https://blog.csdn.net/weixin_45858439/article/details/122215639


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM