1. 程式人生 > 其它 >Nginx(Tengine) 解決 unknown directive "stream" 問題

Nginx(Tengine) 解決 unknown directive "stream" 問題

背景

Nginx(Tengine) 代理 Bitbucket 的 tcp 埠時報錯:unknown directive "stream", 記錄下~

解決

  1. 編譯時,通過新增 --with-stream 引數來安裝 stream 模組。
  2. 需要手工載入 ngx_stream_module.so 模組。
# 作業系統資訊
$ uname -a
Linux oa2 3.10.0-1160.31.1.el7.x86_64 #1 SMP Thu Jun 10 13:32:12 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
$ cat /etc/redhat-release
CentOS Linux release 7.9.2009 (Core)

# Nginx 編譯資訊
$ ./nginx -V
Tengine version: Tengine/2.3.3
nginx version: nginx/1.18.0
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC)
built with OpenSSL 1.0.2k-fips  26 Jan 2017
TLS SNI support enabled
configure arguments: --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_ssl_module --with-http_stub_status_module --with-http_ssl_module --with-http_v2_module --with-http_gzip_static_module --with-http_addition_module --with-stream --with-stream=dynamic --with-stream_ssl_module --with-stream_realip_module --with-http_dav_module --http-proxy-temp-path=/usr/local/nginx/tmp/proxy --http-client-body-temp-path=/usr/local/nginx/tmp/client --http-fastcgi-temp-path=/usr/local/nginx/tmp/fastcgi --http-uwsgi-temp-path=/usr/local/nginx/tmp/uwsgi --http-scgi-temp-path=/usr/local/nginx/tmp/scgi --add-module=/tmp/tengine-2.3.3/modules/ngx_http_upstream_check_module --add-module=/tmp/tengine-2.3.3/modules/ngx_http_proxy_connect_module

# 報錯資訊
$ ./nginx -t
nginx: [emerg] unknown directive "stream" in /usr/local/nginx/conf/nginx.conf:11
nginx: configuration file /usr/local/nginx/conf/nginx.conf test failed

# nginx.conf 第一行加入
$ vi /usr/local/nginx/conf/nginx.conf
load_module /usr/local/nginx/modules/ngx_stream_module.so;
.......

參考

https://serverfault.com/questions/858067/unknown-directive-stream-in-etc-nginx-nginx-conf86