博客列表 >解决nginx: [emerg] unknown directive “stream“ in /etc/nginx/nginx.conf问题

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

哈
原创
2022年04月18日 14:33:025365浏览

镜像下载、域名解析、时间同步请点击 阿里云开源镜像站

问题原因

在nginx中增加了这个配置

  1. [root@k8s-node2 ~]# cat /etc/nginx/nginx.conf
  2. stream {
  3. upstream kube-apiserver {
  4. server 192.168.10.64:6443 max_fails=3 fail_timeout=30s;
  5. server 192.168.10.65:6443 max_fails=3 fail_timeout=30s;
  6. }
  7. server {
  8. listen 7443;
  9. proxy_connect_timeout 2s;
  10. proxy_timeout 900s;
  11. proxy_pass kube-apiserver;
  12. }
  13. }

nginx -t报错

file

解决方法

  1. # 安装nginx源
  2. curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
  3. # 先安装
  4. yum -y install epel-release
  5. #应该是缺少modules模块
  6. yum -y install nginx-all-modules.noarch
  7. 然后在用nginx -t就好了
  8. [root@k8s-node2 ~]# nginx -t
  9. nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
  10. nginx: configuration file /etc/nginx/nginx.conf test is successful

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

声明:本文内容转载自脚本之家,由网友自发贡献,版权归原作者所有,如您发现涉嫌抄袭侵权,请联系admin@php.cn 核实处理。
全部评论
文明上网理性发言,请遵守新闻评论服务协议