nginx stream无法使用的解决办法

2024-03-01 0 353
目录
  • 错误代码
  • 解决办法

错误代码

[root@xxx nginx]# ./sbin/nginx -t
nginx: [emerg] unknown directive \”stream\” in /usr/local/nginx//conf/nginx.conf:118
nginx: configuration file /usr/local/nginx//conf/nginx.conf test failed

#或者这种
[root@xxx nginx]# ./sbin/nginx -t
nginx: [emerg] dlopen() \”/usr/lib64/nginx/modules/ngx_stream_module.so\” failed (/usr/lib64/nginx/modules/ngx_stream_module.so: undefined symbol: ngx_ssl_session_cache_init) in /usr/local/nginx/conf/nginx.conf:2
nginx: configuration file /usr/local/nginx/conf/nginx.conf test failed

解决办法

  • 先删除原有的nginx
  • 重新构建nginx

# 添加使用–with-stream=dynamic 配置
./configure –prefix=/usr/local/nginx/ –with-stream=dynamic
# 然后make make install
make
make install

  • 到/usr/local/nginx/ 中发现多了modules文件夹

[root@fhd nginx]# ll
total 0
drwxr-xr-x 2 root root 333 Mar 9 11:10 conf
drwxr-xr-x 2 root root 40 Mar 9 11:09 html
drwxr-xr-x 2 root root 6 Mar 9 11:09 logs
drwxr-xr-x 2 root root 34 Mar 9 11:09 modules
drwxr-xr-x 2 root root 19 Mar 9 11:09 sbin

  • 修改nginx.conf文件, 在首行添加 load_module /usr/local/nginx/modules/ngx_stream_module.so;

load_module /usr/local/nginx/modules/ngx_stream_module.so;

  • 再次使用stream

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;
}
}

  • 保存配置文件, 并测试配置文件

[root@fhd nginx]# ./sbin/nginx -t
nginx: the configuration file /usr/local/nginx//conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx//conf/nginx.conf test is successful

  • 此时发现测试配置文件通过, 可以成功启动nginx

到此这篇关于nginx stream无法使用的解决办法的文章就介绍到这了,更多相关nginx stream无法使用内容请搜索悠久资源以前的文章或继续浏览下面的相关文章希望大家以后多多支持悠久资源!

收藏 (0) 打赏

感谢您的支持,我会继续努力的!

打开微信/支付宝扫一扫,即可进行扫码打赏哦,分享从这里开始,精彩与您同在
点赞 (0)

悠久资源 Nginx服务器 nginx stream无法使用的解决办法 https://www.u-9.cn/server/nginx/174018.html

常见问题

相关文章

发表评论
暂无评论
官方客服团队

为您解决烦忧 - 24小时在线 专业服务