nginx stream無法使用的解決辦法
更新時間:2024年02月02日 11:54:12 作者:用代碼記錄生活
nginx的stream模塊一般用于tcp/UDP數(shù)據(jù)流的代理和負(fù)載均衡,本文將給大家介紹一下如何解決nginx stream無法使用問題,文中通過代碼示例給大家介紹的非常詳細(xì),需要的朋友可以參考下
錯誤代碼
[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
- 重新構(gòu)建nginx
# 添加使用--with-stream=dynamic 配置 ./configure --prefix=/usr/local/nginx/ --with-stream=dynamic # 然后make make install make make install
- 到/usr/local/nginx/ 中發(fā)現(xiàn)多了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
- 此時發(fā)現(xiàn)測試配置文件通過, 可以成功啟動nginx
到此這篇關(guān)于nginx stream無法使用的解決辦法的文章就介紹到這了,更多相關(guān)nginx stream無法使用內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
nginx通過location配置代理的原理和實(shí)現(xiàn)方式
這篇文章主要介紹了nginx通過location配置代理的原理和實(shí)現(xiàn)方式,具有很好的參考價(jià)值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教2025-03-03
Nginx大并發(fā)優(yōu)化實(shí)戰(zhàn)
這篇文章主要介紹了Nginx大并發(fā)優(yōu)化實(shí)戰(zhàn),文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2019-10-10
nginx rewrite 偽靜態(tài)配置參數(shù)詳細(xì)說明
nginx rewrite 偽靜態(tài)配置參數(shù)和使用例子 附正則使用說明2010-05-05
nginx FastCGI錯誤Primary script unknown解決辦法
這篇文章主要介紹了nginx錯誤Primary script unknown解決辦法,需要的朋友可以參考下2014-03-03

