nginx

关注公众号 jb51net

关闭
首页 > 网站技巧 > 服务器 > nginx > nginx stream无法使用

nginx stream无法使用的解决办法

作者:用代码记录生活

nginx的stream模块一般用于tcp/UDP数据流的代理和负载均衡,本文将给大家介绍一下如何解决nginx stream无法使用问题,文中通过代码示例给大家介绍的非常详细,需要的朋友可以参考下

错误代码

[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

解决办法

# 添加使用--with-stream=dynamic 配置
./configure --prefix=/usr/local/nginx/ --with-stream=dynamic
# 然后make  make install
make
make install
[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
load_module /usr/local/nginx/modules/ngx_stream_module.so;
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 stream无法使用的解决办法的文章就介绍到这了,更多相关nginx stream无法使用内容请搜索脚本之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持脚本之家!

您可能感兴趣的文章:
阅读全文