欢迎光临
我们一直在努力

nginx: [emerg] unknown directive "stream" in /etc/nginx/nginx.conf:13

问题原因

在nginx中增加了这个配置
stream {

log_format main '$remote_addr $upstream_addr - [$time_local] $status $upstream_bytes_sent';

access_log /var/log/nginx/k8s-access.log main;

upstream k8s-apiserver {
server 172.16.102.1:6443; # Master1 APISERVER IP:PORT
server 172.16.102.2:6443; # Master2 APISERVER IP:PORT
}

server {
listen 16443; # 由于nginx与master节点复用,这个监听端口不能是6443,否则会冲突
proxy_pass k8s-apiserver;
}
}

nginx-t报错

[root@k8smaster1 nginx]# nginx -t
nginx: [emerg] unknown directive "stream" in /etc/nginx/nginx.conf:13
nginx: configuration file /etc/nginx/nginx.conf test failed

解决方法


安装epel源
yum install epel-release -y
缺少modules模块
yum install nginx-all-modules.noarch -y
然后nginx -t就好了
[root@k8smaster1 nginx]# nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

赞(0) 打赏
未经允许不得转载:运维那些事 » nginx: [emerg] unknown directive "stream" in /etc/nginx/nginx.conf:13

评论 抢沙发

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

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏