1、nginx版本至少1.9的版本,版本太低没有stream这个功能
2、下载nginx
wget http://nginx.org/download/nginx-1.10.3.tar.gz
tar xvf nginx-1.10.3.tar.gz
3、编译
./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_realip_module --with-http_flv_module --with-http_mp4_module --with-http_gzip_static_module--with-stream --with-stream_ssl_module
make
make install
4、修改配置文件
user nobody;
worker_processes 1;
events {
worker_connections 1024;
}
stream {
server {
listen 12345;
proxy_connect_timeout 1s;
proxy_timeout 3s;
proxy_pass 127.0.0.1:3306;
}
}
5、启动nginx
/usr/local/nginx/sbin/nginx